Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Make facets work correctly with elasticsearch connector.
Create a view with page based on an index
Create facets based on view
Add block to page
View page
Following error appears on the view page
Warning: Undefined array key "facet" in Drupal\elasticsearch_connector\Elasticsearch\Parameters\Builder\SearchBuilder->setFacets() (line 962 of modules/contrib/elasticsearch_connector/src/ElasticSearch/Parameters/Builder/SearchBuilder.php).
I'm using Drupal 9.3.5 and the following modules.
drupal/search_api: 1.x-dev,
drupal/facets: 2.0.x-dev,
Comment | File | Size | Author |
---|---|---|---|
#10 | 3263123-10.patch | 1.72 KB | longwave |
Comments
Comment #2
danharper CreditAttribution: danharper as a volunteer and at hrpr commentedComment #3
danharper CreditAttribution: danharper as a volunteer and at hrpr commentedComment #4
danharper CreditAttribution: danharper as a volunteer and at hrpr commentedComment #5
danharper CreditAttribution: danharper as a volunteer and at hrpr commentedJust to add that I've also tried the stable versions of those modules too and I get the same error
Comment #6
danharper CreditAttribution: danharper as a volunteer and at hrpr commentedComment #7
danharper CreditAttribution: danharper as a volunteer and at hrpr commentedComment #8
barig CreditAttribution: barig at Smile commentedHi,
I have the same issue, I'm using drupal/facets: 1.8, drupal/search_api:1.23.0 and drupal/elasticsearch_connector:dev-8.0.x#ccfde219b47871b4c873f1e66d3facd581ed1582 (because I'm using PHP8.0 and older versions of elasticsearch_connector are not compatible).
Same error on logs:
Warning: Undefined array key "facet" in Drupal\elasticsearch_connector\Elasticsearch\Parameters\Builder\SearchBuilder->setFacets() (line 962 of /project/app/modules/contrib/elasticsearch_connector/src/ElasticSearch/Parameters/Builder/SearchBuilder.php)
Hope someone can fix this or I'll have to go back to Solr instead of ES :-/
Thanks !
Comment #9
phthlaap CreditAttribution: phthlaap as a volunteer and at Kyanon Digital commentedSame issue, someone please help to check.
Comment #10
longwaveThe warning and the empty facet results are two different bugs.
The warning is because $facet_options['facet'] doesn't seem to be set; this is only needed in the case of nested fields which I don't use, I've moved the code inside that code block but it might still be broken for nested fields.
The empty facet results are because the results are collected from Elasticsearch and then never passed back to Search API; this patch adds two lines to fix that.
I changed this back to 8.0.x because facets are working OK for me in 8.x-7.x; the code is very different.
Comment #11
szato CreditAttribution: szato at Brainsum commentedPatch #10 solved the issue. Thank you.
Comment #12
mparker17@danharper, @barig, @phthlaap, @longwave, @szato, we changed how elasticsearch_connector-8.0.x-dev handles facets in #3270464: Investigate search_api_opensearch as base for elasticsearch_connector, and my manual testing showed facets working properly.
May we trouble you to try out the latest 8.0.x-dev release and see if it meets your needs? If it does not, may we trouble you to change this issue's "Status" back to "Needs work"?
(I'm cleaning up issues in the 8.0.x-dev branch as part of a big review of open issues for #3427243: Plan for 8.0.0-alpha release: thank you for your patience with me!)