All reverse references should be considered multiple.
Steps to reproduce:
1.Create Content type with entity reference field which has setting Allowed number of values set to unlimited.
2.Relate more then one entity to your Content type on your reference field.
3.Enable Reverse entity references processor on index and select for id of referenced entity to index.
4.Try to reindex your index.
Result:
Indexing will fail and if you check logs on solr you should get error like multiple values encountered for non multiValued field.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | reverse_reference_prefix_check-3050475-21.patch | 899 bytes | heathergaye |
| #11 | 3050475-11--fix_cardinality_check_list_detection.patch | 681 bytes | drunken monkey |
| #5 | reverse_entity_references-3050475-5.patch | 899 bytes | xsdx |
| #2 | reverse_entity_references-3050475-2.patch | 1.23 KB | xsdx |
Comments
Comment #2
xsdx commentedProviding patch for issue
Comment #3
xsdx commentedComment #4
mkalkbrennerI consider this line to be easier ;-)
Beside this, I think the check should happen on top of the getPropertyPathCardinality() function itself.
A test would be great, but I don't know if you can do it?
Maybe there's an existing test in Search API we should simply run on Solr?
Comment #5
xsdx commentedI agree. Modified patch and attaching :-).
As for test there is a test in search api module. ReverseEntityReferencesTest.php
Comment #6
xsdx commentedComment #7
mkalkbrennerUnfortunately there's no integration test in Search API that runs on a real backend.
Comment #8
ivan616 commentedApplied patch on project after encountering issue.
Issue was appearing when I was setting up Reverse entity references processor and indexing after adding field.
After applying, I managed to index and get correct result.
It worked for me.
Comment #10
mkalkbrennerComment #11
drunken monkeyUseful work-around.
However, I think the proper fix would be to also check for
$property->isList()in\Drupal\search_api_solr\Plugin\search_api\backend\SearchApiSolrBackend::getPropertyPathCardinality.However, this will not fix the problem until #3053603: Entity-typed processor properties don’t support isList() gets committed and becomes available, so for now this workaround definitely makes sense in any case.
Comment #12
drunken monkeySetting back to “Needs review”, but can of course also create a new issue for this.
Comment #13
mkalkbrenner@drunken monkey: Should the committed patch be reverted?
Does the call for isList() lead to "undefined function" with the current release of Search API?
Comment #14
drunken monkeyOnce you can depend on the Search API commit being there, yes. (Not sure how you’d determine that – I don’t think a versioned dependency makes sense for just this? Probably just wait a bit, I’d say.)
No, that’s defined right in the Typed Data API, so will always be there. The Search API patch just made it return the correct value for entity-valued processor fields.
Comment #16
mkalkbrennerComment #18
rosk0Still experiencing this bug with the latest (Search API 8.x-1.14 & Search API Solr 8.x-3.6 ) versions.
Should I open new issue for this ?
Comment #19
d0t15t commentedI'm also getting this error with (Search API 8.x-1.16 & Search API Solr 8.x-3.9).
Comment #20
lukasss commentedI get it with Search API 8.x-1.16 & Search API Solr 4.0.1
Comment #21
heathergaye commentedI also have this problem, Search API Solr 4.0.0.
Most recent patch doesn't fix, because the field's property_path doesn't match to the property array passed to
$this->getPropertyPathCardinality(...), so it drops out of the function with default value 1.Patch reroll from #5 for version 4.
Comment #22
lukasss commented#21 patch worked for me. TNX
Comment #23
karlsheaI think there should be a better way to override this instead of hard-coding for Reverse Entity References. I have a processor that's doing something similar and needs a way of forcing the cardinality to unlimited as well.
Comment #24
karlsheaSee #3153385 for a possible solution.
Comment #25
mkalkbrennerPosting patches on a closed issue is a bad idea.
Comment #26
mkalkbrennerComment #27
karlsheaThis should be fixed by #3153385: Improve field cardinality detection