When testing the patch for a hierarchical entity processor (https://www.drupal.org/node/2625152), the following error occurs:

Solarium\Exception\HttpException while indexing: Solr HTTP error: OK (400) {"responseHeader":{"status":400,"QTime":0},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.common.SolrException"],"msg":"ERROR: [doc=qcwize-solr-entity:node/34445:nl] multiple values encountered for non multiValued field its_publication_type: [2201, 2198]","code":400}} in Solarium\Core\Query\Result\Result->__construct() (line 106 of /var/www/FRIS/vendor/solarium/solarium/library/Solarium/Core/Query/Result/Result.php).

I have a single value field "publication_type" which is a taxonomy term reference. I enabled hierarchical indexing for it.

Should the field be configured as a multiple field or is there a bug in search_api_solr?

see remark by @drunkenmonkey on https://www.drupal.org/node/2625152#comment-11630651:

@ mpp: I'm pretty sure that's just a bug in the Solr backend – the Search API doesn't care about single-valued vs. multi-valued fields anymore. So, unless you can reproduce it with the database backend, you should report it in the Solr module's issue queue.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mpp created an issue. See original summary.

mkalkbrenner’s picture

I have a single value field "publication_type"

multiple values encountered for non multiValued field its_publication_type

Obviously the field isn't really single valued. Mybe that's caused by this new patch. I think we should wait for the final patch before starting debugging.

mpp’s picture

The new patch indeed makes a previously single valued field in Drupal (= field with 1 term reference e.g. "book type") a multiValued property in SOLR (i.c. "book type" + all ancestor types).
We should probably force hierarchical fields to be multivalued in SOLR.

mkalkbrenner’s picture

Category: Support request » Bug report
Priority: Normal » Major
Issue tags: +Needs tests, +beta blocker

We should probably force hierarchical fields to be multivalued in SOLR.

Yes. Therfor we need to extend the logic of SearchApiSolrBackend::getSolrFieldNames() to set fields that are "potentially" hierarchical to multi-valued. That requires to copy some logic of the \Drupal\search_api\Plugin\search_api\processor\AddHierarchy class.

If someone wants to help to get the beta release out faster, we need a test that reproduces the issue first.

mkalkbrenner’s picture

Title: multiple values encountered for non multiValued field » Hierarchical entity references must be treated as multiValued field
Priority: Major » Critical
Status: Active » Needs review
FileSize
5.98 KB

Here's a first patch, but not tested at all. Please provide some feedback.

mpp’s picture

@mkalkbrenner, tested it with a single valued taxonomy term reference (publication_type) which has hierarchical terms, with the patch I no longer see the multiple values encountered for non multiValued field error.

  • mkalkbrenner committed 21f541a on 8.x-1.x
    Issue #2801765 by mkalkbrenner: Hierarchical entity references must be...
mkalkbrenner’s picture

Assigned: Unassigned » mkalkbrenner
Status: Needs review » Fixed
Issue tags: -Needs tests
mpp’s picture

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.