lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahmet Arslan <iori...@yahoo.com>
Subject Re: multivalue fields logic required
Date Thu, 06 May 2010 08:04:41 GMT

> 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.



      

Mime
View raw message