【问题标题】:ElasticSearch: Configuring a custom analyzer implementationElasticSearch:配置自定义分析器实现
【发布时间】:2012-07-16 13:51:45
【问题描述】:

目前我正在评估是否以及如何将基于 lucene 的遗留分析器组件移动到弹性搜索 (0.19.18)。由于遗留代码基于 lucene,我将分析器包装在 es-plugin 中。分析器的配置如下所示:

index.analysis.analyzer.myAnalyzer.type : myAnalyzer
index.analysis.analyzer.default.type: myAnalyzer
index.analysis.analyzer.default_index.type: myAnalyzer
index.analysis.analyzer.default_search.type: myAnalyzer

到目前为止一切顺利。

curl -XGET 'localhost:9200/_analyze' -d 'Some text'

将返回一个包含正确标记的文本的对象,但是

curl -XGET 'localhost:9200/<name-of-my-index>/_analyze' -d 'Some text'

将返回一个根本没有标记的文本。显然,只应用了小写过滤器而不是 myAnalyzer。索引中的对象都没有被正确分析。

索引映射如下所示(head-plugin 的输出):

mappings: {
item: {
    analyzer: myAnalyzer
    properties: {
        id: {
            type: string
        }
        itemnumber: {
            type: string
        }
        articletext: {
            analyzer: myAnalyzer
            type: string
        }
        sortvalue: {
            type: string
        }
        salesstatus: {
            format: dateOptionalTime
            type: date
        }
    }
}
}

由于我是 ES 新手,我无法弄清楚这种行为的真正原因是什么。有人有想法吗?

【问题讨论】:

  • 运行curl -XGET 'localhost:9200/&lt;name-of-my-index&gt;/_settings'会得到什么?
  • {"myIndex":{"settings":{"index.version.created":"190899","index.number_of_replicas":"0","index.number_of_shards":"1"}}}
  • 是否可以在某处发布repro?

标签: lucene elasticsearch jsm


【解决方案1】:

这就是我在 Elasticsearch 中设置自定义默认分析器的方式。

index:
  analysis:
    analyzer:
      default:
        filter: [lowercase]
        tokenizer: whitespace
        type: custom

像魅力一样工作。

【讨论】:

  • 我偶然发现了您的答案,试图在“类型”中使用自定义的已定义分析器,例如“french2”和“custom”成功了!谢谢。
  • 只是强调一下,关键是使用'default'作为自定义分析器名称。
猜你喜欢
  • 2014-10-05
  • 1970-01-01
  • 2014-08-08
  • 1970-01-01
  • 2016-01-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多