我有一个对象被索引到带有大附件的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”的“mapping”行正在做这个技巧,直到我添加了“settings”块,所以关于这一点导致了exclude被忽略。有什么想法吗?提前谢谢!
答案 0 :(得分:3)
试试这个:
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