簡體   English   中英

為什么solr dismax查詢返回空結果集?

[英]Why solr dismax query returns empty resultset?

我正在嘗試使用Dismax Query Parser從solr 4.5獲取索引數據的自由文本搜索結果,但沒有返回結果,並且沒有像這樣的簡單查詢的錯誤:

http://localhost:9999/solr/products/select?q=cuir&qf=text_fr&defType=dismax

並且這些文件存在於索引中:

{ id: 1, label: "Sac à main en cuir" }
{ id: 2, label: "Sac à main en cuir rouge" }

我的schema.xml是:

..
<field name="id" type="int" indexed="true" stored="true" required="true" /> 
<field name="label" type="string" indexed="true" stored="true" required="true" />
...
<copyField source="label" dest="label_fr"/>
<dynamicField name="*_fr" type="text_fr" indexed="true" stored="false" />
...
<fieldType name="text_fr" class="solr.TextField" positionIncrementGap="100">
  <analyzer> 
    <tokenizer class="solr.KeywordTokenizerFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords_french.txt" enablePositionIncrements="true" />
    <filter class="solr.SnowballPorterFilterFactory" language="French"/>
    <filter class="solr.CollationKeyFilterFactory" language="fr" strength="primary" />
  </analyzer>
</fieldType>

並在solrconfig.xml中

...
<requestHandler name="/select" class="solr.SearchHandler">
  <lst name="defaults">
    <str name="echoParams">explicit</str>
    <int name="rows">10</int>
    <str name="defType">dismax</str>
  </lst>
 ...

那么任何想法有什么不對? 為什么沒有結果?

KeywordTokenizer將您的整個索引字符串視為單個標記,因此它與單個單詞查詢不匹配。

相反,您可以嘗試使用StandardTokenizerFactory,或WhitespaceTokenizerFactory或WordDelimiterFilter。

在上面的模式中,您已將字段“label”定義為“string”,並將其視為單個字符串

您應該將fieldType更改為:

<field name="label" type="text_general" indexed="true" stored="true" required="true" />

如上所述,text_general fieldType默認配置了StandardTokenizerFactory。

它會將字段視為文本(或字符串),您將能夠對其執行全文搜索。

注意:在對特定類別進行分面搜索的情況下,FieldType字符串很好,在這種情況下,必須使用String才能獲得更好的結果。 或者你可以做一個CopyField。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM