You can specify a solr field as "multi-valued", and then supply multiple values for it. What that really does is concatenate all the values with a positional gap between them to prevent phrases and other positional queries from traversing the boundary between the distinct values.

-Mike

On 05/10/2012 12:22 PM, Klostermeyer, Michael wrote:
I am attempting to index a DB schema that has a many:one relationship.  I 
assume I would index this within Solr as a 'multivalue=true' field, is that 
correct?

I am currently populating the Solr index w/ a stored procedure in which each DB record is 
"flattened" into a single document in Solr.  I would like one of those Solr document 
fields to contain multiple values from the m:1 table (i.e. [fieldName]=1,3,6,8,7).  I then need to 
be able to do a "fq=fieldname:3" and return the previous record.

My question is: how do I populate Solr with a multi-valued field for many:1 
relationships?  My first guess would be to concatenate all the values from the 
'many' side into a single DB column in the SP, then pipe that column into a 
multivalue=true Solr field.  The DB side of that will be ugly, but would the 
Solr side index this properly?  If so, what would be the delimiter that would 
allow Solr to index each element of the multivalued field?

[Warning: possible tangent below...but I think this question is relevant.  If 
not, tell me and I'll break it out]

I have gone out of my way to "flatten" the data within my SP prior to giving it to Solr.  
For my solution stated above, I would have the following data (Title being the "many" 
side of the m:1, and PK being the Solr unique ID):

PK | Name | Title
Pk_1 | Dwight | Sales, Assistant To The Regional Manager
Pk_2 | Jim | Sales
Pk_3 | Michael | Regional Manger

Below is an example of a non-flattened record set.  How would Solr handle a 
data set in which the following data was indexed:

PK | Name | Title
Pk_1 | Dwight | Sales
Pk_1 | Dwight | Assistant To The Regional Manager
Pk_2 | Jim | Sales
Pk_3 | Michael | Regional Manger

My assumption is that the second Pk_1 record would overwrite the first, thereby losing 
the "Sales" title from Pk_1.  Am I correct on that assumption?

I'm new to this ballgame, so don't be shy about pointing me down a different 
path if I am doing anything incorrectly.

Thanks!

Mike Klostermeyer

Reply via email to