Array storage in Solr

How to store an array of values ​​in the Solr index? I am specifically trying to formulate a schema.xml file.

Consider the following potential Solr document:

ID: 351 Name: Beatles Members: 1) Name: John Instrument: Guitar 2) Name: Paul Instrument: Guitar 3) Name: George Instrument: Bass 4) Name: Ringo Instrument: Drums 

In MySQL, I would have three tables, for example:

 Bands: BandID Name People: PersonID Name Instrument BandsPeople: BandID references Bands(BandID) PersonID references People(PersonID) 

Ignoring the concept that a person can belong to several groups and other advantages of the MySQL approach, my goal is to learn how to store arrays in Solr. The group is just an example and maybe not very good!

An obvious approach for multiple Member would be a field with multiple values:

 <field name="member" stored="true" type="string" multiValued="true" indexed="true"/> 

However, for this field with multiple values, you must have subselections. I do not see any documentation on how to formulate the scheme. Please note that I am using Solr 4. Thank you.

+8
solr
source share
2 answers

There are several answers, but unfortunately none of them use multivalued .

For facet indexed names, your data (one document) will look like this:

 id="351" band="Beatles" member_0="John" instrument_0="Guitar" member_1="Paul" instrument_1="Guitar" ... 

With relatively short lists (shorter than hundreds), the latter is the easiest in size and complexity of your document, but it causes the problem to fall into the client circle in searches.

+8
source share

Lucene has already joined so you can approximate the db schema with them with some caveats, see Grouping and Joining in Lucene / Solr . Solr will also get access to this, check current work

+1
source share

All Articles