Aggregated fields are always declared as multivalued / list causing problems with boosting in search_api_solr

Created on 8 February 2023, over 1 year ago
Updated 25 March 2023, over 1 year ago

Hello people,

We hit a problem in search_api_solr with an error: "can not use FieldCache on multivalued field" when using the boost recent dates processor.

See issue: https://www.drupal.org/project/search_api_solr/issues/3326515 🐛 "can not use FieldCache on multivalued field" error when using boost recent dates processor Fixed

This problem became apparent between versions 4.2.8 and 4.2.9 of search_api_solr.

search_api_solr attempts to identify if a field is single or multi valued to apply the appropriate prefix to the field name.
At one point it calls $field->getDataDefinition()->isList()

See:

https://git.drupalcode.org/project/search_api_solr/-/blob/4.2.9/src/Plug...

For aggregated fields, this always returns true because of this line:

https://git.drupalcode.org/project/search_api/-/blob/8.x-1.28/src/Plugin...

The comment reads:

// Most aggregation types are single-valued, but "Union" isn't, and we
// can't know which will be picked, so err on the side of caution here.

Is it possible to accurately determine the cardinality of the field to update the is_list property?

Trying to work out if this can be fixed in search_api or needs further work arounds in search_api_solr.

Many thanks!

🐛 Bug report
Status

Fixed

Version

1.0

Component

General code

Created by

🇬🇧United Kingdom Finn Lewis

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024