Hi Jonty, I think you have three possible solutions:
1. Use the collapse component with your name field for not have any duplicates documents. 2. Create a simple logic in your index with flags, like one flag to determine the first element of the same document (in your example you will have three differents documents and the fist one wiill have this flag=true). If the search only have name, you will have to set this flag to true, if not, the dept or the student will be defined and you will have one document returned. 3. Do a post-processing of your data. Maybe you will have more solutions but these are what i have thought right now. Regards, Marco Martínez Bautista http://www.paradigmatecnologico.com Avenida de Europa, 26. Ática 5. 3ª Planta 28224 Pozuelo de Alarcón Tel.: 91 352 59 42 2010/5/6 Jonty Rhods <jonty.rh...@gmail.com> > 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. > > > > > > > > > > >