2012-03-16 117 views
0

我solrconfiguration情況如下:Solr的過濾查詢參數

'

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

`

的架構,我用的是:

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

索引完成後,現在搜索結果如下所示:

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

不幸的是,如果我運行查詢的查詢,

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

它不返回任何東西。

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

不會返回一些比賽。

這是什麼,我做錯了?

回答

3

對於過濾器查詢,您應該使用非標記化字段。

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

因爲小面領域往往指定一舉兩得, 人類可讀的文本和向下鑽取查詢值,他們經常 從用於搜索和排序字段建立索引不同:

  • 它們通常未標記化到單獨的詞語
  • 它們通常沒有被映射到下殼體
  • 人們可讀的標點符號通常不會被刪除(雙引號除外)
  • 通常不需要存儲它們,因爲存儲值看起來非常像索引值,而分面機制用於值檢索。