【问题标题】:Elasticsearch and Tire: adding analysis settings breaks exclude from _source?Elasticsearch 和轮胎:添加分析设置中断从_source 中排除?
【发布时间】:2012-08-11 10:44:10
【问题描述】:

我有一个带有大型附件的对象被索引到 Elasticsearch 中,我不想将其存储在 _source 中。在映射中指定“排除”修复了该问题(感谢此处回答的另一个问题),但是当我为过滤器/分析器添加自定义设置时,它以某种方式破坏了排除,我想知道这是轮胎问题还是它只需要以不同的方式指定排除项。

代码如下:

settings analysis: {
  filter: {
    ngram_filter: {
      type: "nGram",
      min_gram: 2,
      max_gram: 12
    }
  },
  index_analyzer: {
    index_ngram_analyzer: {
      type: "custom",
      tokenizer: "standard",
      filter: ["lowercase", "ngram_filter"]
    }
  },
  search_analyzer: {
    search_ngram_analyzer: {
      type: "custom",
      tokenizer: "standard",
      filter: ["standard", "lowercase", "ngram_filter"]
    }
  }
} do
  mapping :_source => { :excludes => ['attachment'] } do
    indexes :id, :type => 'integer'
    [:title, :abstract].each do |attribute|
      indexes attribute, type: 'string', analyzer: 'ngram_analyzer'
    end
    indexes :attachment, :type => 'attachment'
  end
end

在我添加了“设置”块之前,带有“:excludes”的“映射”行一直在起作用,因此有关此的某些内容导致排除被忽略。有什么想法吗?提前致谢!

【问题讨论】:

    标签: elasticsearch tire


    【解决方案1】:

    试试这个:

    settings :analysis => {
      :filter  => {
        :ngram_filter => {
          :type => "nGram",
          :min_gram => 2,
          :max_gram => 12
        }
      },
      :analyzer => {
        :index_ngram_analyzer => {
          :type  => "custom",
          :tokenizer  => "standard",
          :filter  => ["lowercase", "ngram_filter"]
        },
        :search_ngram_analyzer => {
          :type  => "custom",
          :tokenizer  => "standard",
          :filter  => ["standard", "lowercase", "ngram_filter"]
        }
      }
    } do
      mapping :_source => { :excludes => ['attachment'] } do
        indexes :id, :type => 'integer'
        [:title, :abstract].each do |attribute|
          indexes attribute, :type => 'string', :index_analyzer => 'index_ngram_analyzer', :search_analyzer => 'search_ngram_analyzer'
        end
        indexes :attachment, :type => 'attachment'
      end
    end
    

    【讨论】:

    • 啊...谢谢。将轮胎中的符号“映射”到 Elasticsearch 中的键需要一些时间来适应,但这有助于澄清很多。问题已解决,再次感谢!
    猜你喜欢
    • 1970-01-01
    • 2013-09-26
    • 2012-06-04
    • 2012-03-29
    • 1970-01-01
    • 1970-01-01
    • 2012-08-24
    • 1970-01-01
    • 2012-10-19
    相关资源
    最近更新 更多