thanks :General solution is to index 3 different SolrDocument in your example. id and name fields will repeat themselves. All fields will be single-valued.
if I am indexing 3 different field then if user is searching by name + dept then it will return duplicate value.. is there any other best possible way..? thanks On Thu, May 6, 2010 at 1:34 PM, Ahmet Arslan <iori...@yahoo.com> wrote: > > > recently I start to work on solr, So I am still very new to > > use solr. Sorry > > if I am logically wrong. > > I have two table, parent and referenced (child). > > > > for that I set multivalue field following is my schema > > details > > <field name="id" type="string" indexed="true" > > stored="true" required="true" > > /> > > > > > > <field name="name" type="text" > > indexed="true" stored="true"/> > > > > <field name="dept" type="text" > > indexed="true" stored="true" > > multiValued="true"/> > > <field name="city" type="text" > > indexed="true" stored="true" > > multiValued="true"/> > > > > indexed data details: > > > > <doc> > > > > <arr name="dept"> > > <str>student1</str> > > <str>student2</str> > > <str>student3</str> > > </arr> > > > > <arr name="city"> > > <str>city1</str> > > <str>city2</str> > > <str>city3</str> > > </arr> > > <str name="id">1</str> > > > > <arr name="name"> > > <str>name of emp</str> > > </arr> > > > > </doc> > > > > now my question is : > > When user is searching by city2 then I want to return > > employee2 and their id > > (for multi value field). > > something like: > > > > <doc> > > > > <arr name="dept"> > > > > <str>student2</str> > > > > </arr> > > > > <arr name="city"> > > > > <str>city2</str> > > > > </arr> > > <str name="id">1</str> > > > > <arr name="name"> > > <str>name of emp</str> > > </arr> > > > > </doc> > > > > I had a similar need before. AFAIK you cannot do it with multivalued > fields. The indexing order is preserved in multivalued field. May be you can > post-process returned fields and capture correct position of matched city > field, and use this index to display correct dept value. But this is easy if > you are using string or integer type for city and dept. > > General solution is to index 3 different SolrDocument in your example. id > and name fields will repeat themselves. All fields will be single-valued. > > > > >