nicck_par
nicck_par

Reputation: 83

solr filtered query parameter

My solrconfiguration is as follow:

`

 <lst name="defaults">
    <str name="defType">dismax</str>
    <str name="q.alt">*:*</str>
    <str name="qf">
        city^10.0 name^10.0 city_l10n_value^10.0 name_l10n_value^10.0 state^5.0 country^2.0
    </str>
    <str name="sort">hotel_count desc,query({!v="type:(airport OR train_station)"}) desc ,score desc</str>
    <str name="tie">0.1</str>
   <str name="echoParams">explicit</str>
   <int name="rows">100</int>
 </lst>

`

The Schema, I am using is :

<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
   <filter class="solr.LengthFilterFactory" min="2" max="100"/>      
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="German2" />        
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    <filter class="solr.LengthFilterFactory" min="2" max="100"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.SnowballPorterFilterFactory" language="German2" />        
  </analyzer>
</fieldType>
<field name="type" type="text_general" indexed="true" stored="true"/>
......

Now after indexing search results looks like following:

<result name="response" numFound="114" start="0">
<doc><str name="type">airport</str></doc>
<doc><str name="type">train_station</str></doc>
<doc><str name="type">tourist_feature</str></doc>
<doc><str name="type">company_location</str></doc>
<doc><str name="type">company_location</str></doc>
<doc><str name="type">company_location</str></doc>
<doc><str name="type">company_location</str></doc>
<doc><str name="type">company_location</str></doc>

Unfortunately if I run the query the query,

http://localhost:8983/solr/maincore/select/?fq=type:company_location,

it does not return anything.

http://localhost:8983/solr/maincore/select/?fq=type:tourist_feature

does return some match.

What is it, which I am doing wrong?

Upvotes: 0

Views: 771

Answers (1)

Jayendra
Jayendra

Reputation: 52769

For filter queries you should use non tokenized fields.

http://wiki.apache.org/solr/SolrFacetingOverview

Because faceting fields are often specified to serve two purposes, human-readable text and drill-down query value, they are frequently indexed differently from fields used for searching and sorting:

  • They are often not tokenized into separate words
  • They are often not mapped into lower case
  • Human-readable punctuation is often not removed (other than double-quotes)
  • There is often no need to store them, since stored values would look much like indexed values and the faceting mechanism is used for value retrieval.

Upvotes: 4

Related Questions