Dennis,

I may be misunderstanding your question, but think I've just worked through 
something similar.  We're indexing book metadata, and a book can have more than 
one Contributor.  We want to store both the contributor's name, their Role and 
their id (from our rel db).  With our old system, we had to do something like 
this:

contrib:  dyer, james|author|123
contrib:  smith, sam|editor|456

But Lucene/Solr will guanantee that multivalued fields return in exactly the 
same order you put them in.  So with SOLR we can do this:

contrib_name: dyer, james
contrib_name: smith, sam
contrib_role: author
contrib_role: editor
contrib_id:123
contrib_id:456

The trick is to be very careful you put everything in the same order (its easy 
if it is all from the same SQL query from an relational database).  If one of 
the data elements is a NULL you have to use a placeholder (like an empty string 
or a zero).

Another option is use a dynamic field:

contrib_123: dyer, james
contrib_456: smith, sam

The problem here is if you want to display and use a fieldlist (fl=), you 
cannot use wildcards (ex: fl=contrib_* doesn't work).  Same for searching (q=, 
qf=).  You can only use dynamic fields if you know the fieldname at runtime you 
need to deal with.

Both of these options might be more work for your app to deal than the 
delimiter approach.  And, in our case, we could stick with the delimiter field 
and store it and then have a separate indexed field that just has the name (as 
this is all we search on).  You could even just have 1 field if you used a 
fancy analysis sequence that would only index the element(s) you wanted 
indexes...

James Dyer
E-Commerce Systems
Ingram Content Group
(615) 213-4311


-----Original Message-----
From: Dennis Gearon [mailto:gear...@sbcglobal.net] 
Sent: Friday, December 17, 2010 12:43 AM
To: solr-user@lucene.apache.org
Subject: A schema inside a Solr Schema (Schema in a can)

Is it possible to put name value pairs of any type in a native Solr Index field 
type? Like JSON/XML/YML?

The reason that I ask, since you asked, is I want my main index schema to be a 
base object, and another multivalue column to be the attributes of base object 
inherited descendants. 

Is there any other way to do this?

What are the limitations in searching and indexing documents with multivalue 
fields?

Dennis Gearon

Signature Warning
----------------
It is always a good idea to learn from your own mistakes. It is usually a 
better idea to learn from others’ mistakes, so you do not have to make them 
yourself. from 'http://blogs.techrepublic.com.com/security/?p=4501&tag=nl.e036'

EARTH has a Right To Life,
  otherwise we all die.

Reply via email to