【问题标题】:SOLR querying "less than" and "greather than" symbolsSOLR 查询“小于”和“大于”符号
【发布时间】:2016-10-05 16:15:09
【问题描述】:

SOLR 中的一个字段,我们称之为Customers_txt,其值如下:

qwe<asd>zxc

我正在尝试这样查询:

Customers_txt:(*qwe<asd>zxc*)

但是查询执行时没有结果。 如果我这样查询它

Customers_txt:(*qwe*)

我得到结果

"Customers_txt": [ "qwe<asd>zcx"]

但有可能我会发现很多不必要的记录,其中包含qwe 作为字符串的一部分。 如果我在没有* 的情况下执行查询,就像Customers_txt:(qwe&lt;asd&gt;zxc) 我得到结果。但即使这是一个子字符串,我也需要找到它,比如说AAAqwe&lt;asd&gt;zxcAAA,所以我需要这些星号。 但我也需要找到其中包含这些特殊符号的字符串(&lt;&gt;)。 这也适用于符号[]:

【问题讨论】:

    标签: solr lucene lucene.net solrnet


    【解决方案1】:

    您应该尝试以下提到的事情:

    • 您需要查看 schema.xml 文件,您为 字段类型使用了哪些标记器/过滤器工厂?

    • 还尝试在 Solr 管理面板上使用 debugQuery=true 执行此查询,看看正在解析的查询是什么?

    【讨论】:

    • 这是使用的 fieldType &lt;fieldType name="text_general" class="solr.TextField" positionIncrementGap="100"&gt; &lt;analyzer&gt; &lt;charFilter class="solr.HTMLStripCharFilterFactory"/&gt; &lt;tokenizer class="solr.KeywordTokenizerFactory"/&gt; &lt;filter class="solr.LowerCaseFilterFactory"/&gt; &lt;/analyzer&gt; &lt;/fieldType&gt;
    • 和debugQuery的结果"debug": { "rawquerystring": "Customers_txt:(*iop&lt;oip&gt;opi*)", "querystring": "Customers_txt:(*iop&lt;oip&gt;opi*)", "parsedquery": "Customers_txt:*iop&lt;oip&gt;opi*", "parsedquery_toString": "Customers_txt:*iop&lt;oip&gt;opi*", "explain": {}, "QParser": "LuceneQParser",
    • 我没有时间深入研究它。如果您遇到尖括号等特殊字符的问题;你试过用“?”替换这些。您的查询将如下所示:*iop?oip?opi*
    • 不,它没有帮助。看起来 SOLR 不搜索 '' 作为 '?' 的替代品
    猜你喜欢
    • 2013-01-10
    • 1970-01-01
    • 1970-01-01
    • 2019-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-18
    • 1970-01-01
    相关资源
    最近更新 更多