tags:

views:

411

answers:

1

Hi there! I’m doing some faceted searches but have a few problems. I don’t get the desired results when there are several words in the faceted search field.

Example: “animal” field with the following entries:

        A horse

        Black horse

        Black horse

La faceted search sends back "horse(3)" as best result, whereas I would like to get back "Black horse(2)".

And this is the schema.xml. The search field is BUSQUEDA, and the faceted field is SUPERFICIE. I think I have tried most of the posible combinations of the defined types for these two fields but still doesn't work.

<?xml version="1.0" encoding="UTF-8" ?>
        <schema name="example" version="1.2">
         <types>

     <fieldType name="string" class="solr.StrField"/>

    <fieldType name="facet_texPersonal" class="solr.StrField" sortMissingLast="true" omitNorms="true">
           <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
           </analyzer>
          </fieldType>

          <fieldType name="facet_tex" class="solr.TextField" sortMissingLast="true" omitNorms="true">
           <analyzer>
            <tokenizer class="solr.KeywordTokenizerFactory"/>
            <filter class="solr.LowerCaseFilterFactory" />
            <filter class="solr.TrimFilterFactory" />
           </analyzer>
          </fieldType>

          <fieldType name="text" class="solr.TextField" positionIncrementGap="100">
           <analyzer type="index">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"
             enablePositionIncrements="true"/>
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" 
             catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="1"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
           </analyzer>
           <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" 
             enablePositionIncrements="true"/>
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" 
             catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="1"/>
            <filter class="solr.LowerCaseFilterFactory"/>
            <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
           </analyzer>
          </fieldType>

          <fieldType name="textTight" class="solr.TextField" positionIncrementGap="100" >
            <analyzer>
           <tokenizer class="solr.WhitespaceTokenizerFactory"/>
           <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="false"/>
           <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
           <filter class="solr.WordDelimiterFilterFactory" generateWordParts="0" generateNumberParts="0"        catenateWords="1" catenateNumbers="1" catenateAll="0"/>
           <filter class="solr.LowerCaseFilterFactory"/>
           <filter class="solr.SnowballPorterFilterFactory" language="English" protected="protwords.txt"/>
           <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
            </analyzer>
          </fieldType>

          <fieldType name="textMultidioma" class="solr.TextField" positionIncrementGap="100">
           <analyzer type="index">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" 
              enablePositionIncrements="true" />
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" 
              catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0"/>
            <filter class="solr.LowerCaseFilterFactory"/>
           </analyzer>
           <analyzer type="query">
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
            <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true"/>
            <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" 
             catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0"/>
            <filter class="solr.LowerCaseFilterFactory"/>
           </analyzer>
          </fieldType>

         </types>

         <fields>
          <field name="BUSQUEDA" type="facet_tex" indexed="true" stored="true"/>
          <field name="SUPERFICIE" type="facet_tex" indexed="true" stored="true"/>
          <field name="NOMBRE" type="string" indexed="true" stored="true"/>
         </fields>
         <uniqueKey>NOMBRE</uniqueKey>
         <defaultSearchField>BUSQUEDA</defaultSearchField></schema>

Any suggestions?

Thanks a bunch in advance!

+1  A: 

You have to facet on a non-tokenized field (field class solr.StrField, or using solr.KeywordTokenizerFactory). This thread explains it in detail.

Mauricio Scheffer
Thanks very much
Carlos
I have been trying to do it, but it doesn't seem to work. I am still getting the same results. Anyway, thanks for your help
Carlos
@Carlos: what have you tried? post your schema.xml
Mauricio Scheffer
I have tried with BUSQUEDA being "facet_texPersonal" and what I get is:A(1)Black(2)It is like if it only considered the first word
Carlos