我正在嘗試用Solr.Net搜索Solr實例。我有場body
它在架構中定義爲:Solr.Net查詢返回錯誤結果
<field name="body"
type="text_general"
indexed="true"
stored="true"
omitNorms="true"/>
text_general
使用的架構solr.StandardTokenizerFactory
並定義爲:
<fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<!-- in this example, we will only use synonyms at query time
<filter class="solr.SynonymFilterFactory" synonyms="index_synonyms.txt" ignoreCase="true" expand="false"/>
-->
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.StandardTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" />
<filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
(我還沒有與此字段類型改變任何東西,它是一個我得到了solr的默認安裝)
我想查詢記錄對搜索詞LISTBU5.RCV
,它返回包含LISTBU4.RCV
的結果。像:
Items left on queue: \\111.11.11.11\Lists\SAVELIST\ABC2\LISTBU4.RCV
假的結果:在搜索項末尾的數量是不同的
我的查詢代碼:
SolrQueryByField solrQuery = new SolrQueryByField("body", searchTerm);
var result = solr.Query(solrQuery, new SolrNet.Commands.Parameters.QueryOptions
{
Rows = 100, //
Start = 0,
OrderBy = new[] { new SortOrder("ID", Order.DESC) },
});
但是,如果使用文本查詢,如:
SolrQuery solrQuery = new SolrQuery("(body:" + "\"" + searchTerm + "\")");
它返回確切結果。我知道在Solr.Net
中不鼓勵創建文本查詢,但我應該怎麼做呢?
我使用SolrNet.dll
版本0.4.0.2002
與Solr實例4.4.0
版本。
試過了,不起作用。這返回相同的結果。 – user2711965
與簡單的文本查詢它按預期工作,我指定在我的問題以及。在Solr Web UI中,如果我也能得到預期的結果。它只是'SolrQueryByField',它沒有給出正確的結果。我相信我已經找到了解決方案,併發布相同的答案。 – user2711965