You should do a preprocessing(multiply your document as many documents as values you have in your multivalue field, with the principalFlag:T in your first document) before you indexing the data with that logic
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/12 Jonty Rhods <jonty.rh...@gmail.com> > hi Marco, > > Thanks for quick reply.. > I have another doubt: In 2nd solution: How to set flag for duplicate value. > because I am not sure about the no fo duplicate rows (it could be random > no..) > so how can I set the flag.. > thank > > On Wed, May 12, 2010 at 12:59 PM, Marco Martinez < > mmarti...@paradigmatecnologico.com> wrote: > > > Hi, > > > > 2º solution: > > > > Not use multiValue fields, instead use two single fields, in your example > > will be: > > > > doc1: > > dept: student1 > > city: city1 > > principalFlag:T > > doc2: > > dept: student2 > > city: city2 > > principalFlag:F > > > > So, if you search without specify any city or dept, you should put > > princiaplFlag:T for no get duplicate on your response. And if you specify > a > > city or a dept, there is no need to specify the principalFlag because you > > will only get the result that match with your fields (you dont get > > duplicates). > > > > 3º solution: > > > > Do a postprocessing to eleminate the fields in your response that you > dont > > need, i mean, get only the city and the dept that should be in the query > > response. > > > > Hope this will help > > > > > > > > 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/12 Jonty Rhods <jonty.rh...@gmail.com> > > > > > Hi Marco, > > > > > > I am trying to patch for collapse component support (till now no > luck).. > > > In mean time I would like to know the 2nd and 3rd option you mentioned > > > (logic in solrj).. > > > > > > with regards > > > > > > On Thu, May 6, 2010 at 2:36 PM, Marco Martinez < > > > mmarti...@paradigmatecnologico.com> wrote: > > > > > > > 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. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >