Closed (works as designed)
Project:
Apache Solr Search
Version:
6.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Jan 2013 at 04:18 UTC
Updated:
23 May 2013 at 18:57 UTC
Jump to comment: Most recent file
Comments
Comment #1
nick_vhWhat version of Solr are you using? I've encountered this with Solr 4. I've seen this happening with hierarchic taxonomy fields. Can you try latest dev version and see if it is resolved? (patched something about this problem last weekend)
Comment #2
nick_vhapachesolr_nodereference_indexing_callback should probably check if the field is single valued and only allow 1 value if that is the case.
Could one of you tell me what is in the $field_info for your specific case?
Comment #3
remimikalsen commentedI'm using 7.x-1.1 regularly and it seems 7.x-1.x-dev (downloaded today) introduces a bug on entity-reference to taxonomy terms. I have a field that is an entity-reference to an unlimited number of taxonomy terms of a particular vocabulary. The apachesolr status page for facets identifies the field as an ss_ field, but it's attemted indexed as an sm_ field (which of course fails terribly on the solr-side). Solr 3.6 here, but it's really not a Solr problem.
I'll try to be more explicit on the nature of this bug when I have some time on my hands. For now I'll just have to "put it out there".
R
Comment #4
nick_vhNo time is no excuse, really. Just put a debug statement there and paste it here. :)
Comment #5
remimikalsen commented* apachesolr_entityreference_indexing_callback
* dd($field_info);
Gives:
(Note the multiple field; here it holds nothing. The stable version holds "1")
Comment #6
nick_vhSo 'multiple' seems to be false, apachesolr correctly gives it a singular field. I assume that the assignment of entityreference keys is done incorrectly somehow.
Could you also do a debug of the apachesolr_entity_fields();function? Perhaps we have to force all reference fields to be multiple in any case?
Comment #7
remimikalsen commentedIn apachesolr_entity_fields() there is:
Append immediately after:
Solves it for me. Maybe the !==0 is redundant. In any case, cardinality -1 or >1 are the multiples.
Comment #8
nick_vhInteresting, could you make a patch? And add some documentation about the cardinality field.
eg.: cardinality (integer): The number of values the field can hold. Legal values are any positive integer or FIELD_CARDINALITY_UNLIMITED.
http://api.drupal.org/api/drupal/modules%21field%21field.module/group/fi...
So it's only when the value == 1, we should set a field to single. -1 is unlimited and anything else means multiple. I'm not sure what 0 does. Also, we might want to rename multiple throughout the codebase to cardinality to sync more with D7?
Comment #9
remimikalsen commentedSee attached patch.
Comment #10
nick_vhWe also want to check if the field is set, so you can do an isset($field['cardinality]) && $field['cardinality'] !== 1
Comment #11
remimikalsen commentedAttached patch v2.
I assumed it must hold positive integer or FIELD_CARDINALITY_UNLIMITED, but better safe than sorry; guess an isset doesn't "cost" all that much.
Comment #12
ianthomas_ukIs there a reason to use !== instead of just !=? Are we sure it will never be '1'?
Setting to needs review to get picked up by automated tests.
Comment #13
remimikalsen commentedI'm not sure of that, But if a '1' is found, maybe it should be fixed by the code that violates the documented behaviour?
R
Comment #14
nick_vhYou can just use !=, makes it less strict, but more certain that even custom code will be picked up.
Comment #15
remimikalsen commentedComment #16
nick_vhComment #17
mkalkbrennerSomething similar here:
In our case, field_testimonial is a multi value entity reference on a node.
#15 solved the issue.
Comment #18
albert78 commentedPatch from #15 solved my issue as well.
Comment #19
steven.wichers commentedAlso confirming #15 seems to have fixed the issue for us.
Comment #20
swentel commentedBeen bitten by this as well. Rerolled for 80 chars limit and removed the isset(). @nick, field api adds defaults, also for cardinality (defaults to 1), so the property is always set. Still RTBC.
Comment #21
swentel commentedBAH
Comment #22
nick_vhNot sure if it needs backport, but marking as such until someone confirms. Committed to 7.x-1.x
Comment #23
wonder95 commentedAttached is a patch for a backport to 6.x-3.x.
Comment #24
wonder95 commentedComment #25
nick_vhDrupal 6 does not have the cardinality config, only multiple. So due to that it is not applicable and I am going to close this issue.