【问题标题】:Analyzing the same search field twice returns 0 results on subfield in ElasticSearch分析同一搜索字段两次在 ElasticSearch 中的子字段上返回 0 个结果
【发布时间】:2016-06-26 10:38:28
【问题描述】:

我有一个名为 search_text 的字段,它是一个全文搜索字段。

我正在使用 ngrams 来索引这个字段,我想添加一个新的子字段 search_text.words 来索引整个单词。

我尝试实现这一点,但查询search_text.words 总是返回 0 个命中。

我是这样创建的:

  "search_text" => {
      "type" => "string",
      "analyzer" => "ngram",
      "search_analyzer" => "ngram_search",
      "fields" => {
          "words" => {"type" => "string",
                      "analyzer" => "ngram_search"}
      }
  }

我在这里有一个完整的演示:

https://www.dropbox.com/s/wwxm3qe0oxc2z5y/Slimmed%20ElasticSearch%20Text%20%281%29.html?dl=0

【问题讨论】:

  • 非常类似于你的另一个问题stackoverflow.com/questions/35798886/…,我还是要回答:)
  • 是的,我试图改写它,因为从技术上讲,另一个问题的回答是错误地将设置放置在错误的位置。感谢您到目前为止的帮助:)

标签: ruby elasticsearch elasticsearch-ruby


【解决方案1】:

查看您的保管箱文件,我认为问题在于映射类型称为search_variable,而在您的批量查询中,您使用的是映射类型test_type

因此永远不会应用映射。

如果您将批量查询更改为此,它将起作用

bulk_insert_items = items_to_insert.flat_map do |item|
      [
        {index: {_index: 'test_index', _type: 'search_variable'}},
        item
      ]
end

【讨论】:

    猜你喜欢
    • 2020-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多