【问题标题】:Elasticsearch is not generating numeric tokensElasticsearch 没有生成数字标记
【发布时间】:2017-02-25 11:01:54
【问题描述】:

我无法让 Elasticsearch 在诸如 15 pound chocolate cake 之类的短语上生成正确的标记。在该字段上执行和fielddata_field 查询时,它将产生以下结果:

pou poun pound cho choc choco chocol chocola chocolat chocolate cak cake

我根本看不到里面的数字。我尝试了几种不同的分析器选项组合,但均无济于事。以下是我的映射:

{ "settings" : { "index" : { "analysis": { "filter": { "nGram_filter": { "type": "edge_ngram", "min_gram": 3, "max_gram": 20 }, "my_word": { "type":"word_delimiter", "preserve_original": "true" } }, "analyzer": { "nGram_analyzer": { "type": "custom", "tokenizer": "standard", "filter": [ "standard", "lowercase", "asciifolding", "my_word", "nGram_filter" ] }, "whitespace_analyzer": { "type": "custom", "tokenizer": "whitespace", "filter": [ "lowercase", "asciifolding" ] } } }} }, "mappings": { "categories": { "properties": { "id": {"type": "text"}, "sort": {"type": "long"}, "search_term":{"type":"text","analyzer": "nGram_analyzer","search_analyzer": "whitespace_analyzer", "fielddata":true} } } } }

我尝试了nGram 过滤器,例如:

"nGram_filter": { "type": "edge_ngram", "min_gram": 3, "max_gram": 20, "token_chars": [ "letter", "digit", "punctuation", "symbol" ] }

word_delimiter 上设置"generate_number_parts": "true" "generate_word_parts": true 也没有帮助。

编辑 我通过将min_gram 大小更改为 2 来使其工作,但我希望将其保持在 3。我想知道是否有办法保持克大小为 3,同时保持数字不变?

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    行为符合预期。这不是数字标记的问题,而是术语长度的问题。即使您有一个包含 1 或 2 个字符的字符串,它也会被过滤掉。

    min_gram :一克中字符的最小长度。默认为 1

    任何字符数少于 min gram 的标记都将被过滤掉

    因此,在这种情况下,15 被过滤掉了。

    【讨论】:

    • 有没有其他方法可以完成我想要的你知道的事情?
    • 不将 min_gram 大小更改为 2 的任何具体原因?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-22
    • 2018-06-14
    • 2012-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多