【问题标题】:solr search - Result missing if I miss a word located between two wordssolr search - 如果我错过位于两个单词之间的单词,则结果丢失
【发布时间】:2018-04-06 08:45:33
【问题描述】:

我在使用 Solr 进行搜索时遇到问题。 我索引了一些数据,然后尝试搜索文档。 在本文档中,我的字段名为:coord_address,其值为 "48 rue de la Frémondière" 如果我搜索 searchword: "48 rue de la Fremondiere",我会得到一个结果,searchword: "48 rue de la""La Fremondiere" strong> 我也有好的结果。

如果我通过删除 (le) 或 (48 rue la Fremondiere 错过了位于两个单词 (48 rue de Fremondiere) 之间的单词>) 删除 (de) 我没有结果。

有人可以帮助我。

这是我的 schema.xml

<field name="coord_adress" type="text"  indexed="true"  stored="true" multiValued="false" />


<fieldType name="text" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="false">
   <analyzer type="index">
        <!-- Remplace les apostrophes par des espaces pour le tokenizer -->
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-wordSeparators.txt"/>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="1" catenateAll="0"  preserveOriginal="1"/>
        <filter class="solr.ASCIIFoldingFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="30"/>
   </analyzer>
   <analyzer type="query">
        <!-- Remplace les apostrophes par des espaces pour le tokenizer -->
        <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-wordSeparators.txt"/>
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0"  preserveOriginal="1"/>
        <filter class="solr.ASCIIFoldingFilterFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
   </analyzer>
</fieldType>

什么我不明白,在界面分析中,我有匹配的术语但我的查询没有返回结果

See the screenshot of the analysis here

【问题讨论】:

  • 您使用的是哪个查询?只是术语查询或更复杂的东西?
  • 我正在使用 solr Web 界面进行查询。我的请求是:http://localhost:8983/solr/adel_online/select? Indent = on & q = coord_adress: "48 rue de la Fremondiere" & wt = json 这个请求返回了一个很好的结果并且 http://localhost:8983/solr/adel_online/select? Indent = on & q = coord_address: "48 rue la Fremondiere" & wt = json 不返回任何结果,因为我删除了 (de)

标签: java search solr tokenize stop-words


【解决方案1】:

那是因为您使用了双引号,这意味着您正在搜索完全匹配的短语。

删除引号,搜索应该在这两种情况下都有效。

当您需要了解某些索引和查询输入的行为时,始终建议使用 Solr 分析工具:https://lucene.apache.org/solr/guide/6_6/analysis-screen.html

【讨论】:

  • 如果我删除引号,我会得到这样的结果:{ "responseHeader": { "status": 400, "QTime": 0, "params": { "q": " coord_adresse2:48 rue de la Frémondière”,“缩进”:“on”,“wt”:“json”,“”:“1508934662307”}},“错误”:{“元数据”:[“错误- class", "org.apache.solr.common.SolrException", "root-error-class", "org.apache.solr.common.SolrException"], "msg": "未定义字段 _text", “代码”:400}}
  • 您已将查询中的字段更改为 coord_adresse2。尝试使用原始 coord_adress,如果不起作用,请提供请求 url。
  • 对不起,我的字段名称有误。 coord_adress 字段的名称和不提供任何结果的请求 url 为:http://localhost:8983/solr/adel_online/select?缩进 = on & q = coord_adress: 48 rue la Fremondiere & wt = json。 solr 中的字段包含 "coord_adress": "48 rue de la Fremondiere"
  • 尝试使用您的 solr 管理页面中的 solr 分析选项卡来了解您的索引和查询输入发生了什么:lucene.apache.org/solr/guide/6_6/analysis-screen.html
  • 这是因为如果查询中未提供字段,则默认搜索字段为_text_。由于您仅在第一个术语 (48) 前加上字段名称,因此将尝试将其余术语与不存在的默认字段进行匹配。使用 edismax 查询处理程序 (&amp;defType=edismax),coord_adress 作为查询字段 (&amp;qf=coord_adress) 和普通查询作为您的查询 (q=48 rue de la Frémondière)。该错误与分析链无关。
猜你喜欢
  • 1970-01-01
  • 2020-06-09
  • 1970-01-01
  • 1970-01-01
  • 2015-09-08
  • 1970-01-01
  • 2021-09-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多