You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Lucas Miguez <lu...@gmail.com> on 2011/07/13 18:51:45 UTC

Multivalued field: get only the str that matches with the query

Hi all,

I have a multivalued field. I need to make a search in the multivalued
field and get only the values that match with the query.

Example:

<doc>
<field name="text">aaa bbb ccc</field>
<field name="text">aaa</field>
<field name="text">ccc</field>
</doc>

So, if I make a search like "text:aaa" the 3 values are returned, when
only results one and two are the correct.

I am using the WhitespaceTokenizer in the index and in the query analyzers:
<types>
   <fieldtype name="string"  class="solr.TextField"
positionIncrementGap="100" autoGeneratePhraseQueries="true">
   <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
   </analyzer>
   <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
	</analyzer>
   </fieldtype>
  </types>


How to do that on Apache Solr?

Thanks!

Re: Multivalued field: get only the str that matches with the query

Posted by Tomás Fernández Löbbe <to...@gmail.com>.
I once achieve this by using the highlighting feature, I don't know if there
is a more direct way of doing it.

On Wed, Jul 13, 2011 at 1:51 PM, Lucas Miguez <lu...@gmail.com>wrote:

> Hi all,
>
> I have a multivalued field. I need to make a search in the multivalued
> field and get only the values that match with the query.
>
> Example:
>
> <doc>
> <field name="text">aaa bbb ccc</field>
> <field name="text">aaa</field>
> <field name="text">ccc</field>
> </doc>
>
> So, if I make a search like "text:aaa" the 3 values are returned, when
> only results one and two are the correct.
>
> I am using the WhitespaceTokenizer in the index and in the query analyzers:
> <types>
>   <fieldtype name="string"  class="solr.TextField"
> positionIncrementGap="100" autoGeneratePhraseQueries="true">
>   <analyzer type="index">
>        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>   </analyzer>
>   <analyzer type="query">
>        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
>        </analyzer>
>   </fieldtype>
>  </types>
>
>
> How to do that on Apache Solr?
>
> Thanks!
>