【问题标题】:Elasticsearch version 5.0.1 , search analyse isn't working.Elasticsearch 5.0.1 版,搜索分析不起作用。
【发布时间】:2017-12-28 00:31:27
【问题描述】:

我是 Elasticsearch 的新手。我们正在使用 Elasticsearch 5.0.1,我正在尝试创建一个索引,如下所示。我确实浏览了 Elastic search 的文档和此处的一些帖子,但无法使用以下所需设置创建索引

 PUT testv2 
 {
     "settings": {
         "index": {
            "number_of_shards": "5",

        "analysis": {
            "filter": {
                "nGram_filter": {
                    "token_chars": [
                        "letter",
                        "digit",
                        "punctuation",
                        "symbol"
                    ],
                    "min_gram": "2",
                    "type": "nGram",
                    "max_gram": "20"
                }
            },
            "analyzer": {
                "nGram_analyzer": {
                    "filter": [
                        "lowercase",
                        "asciifolding",
                        "nGram_filter"
                    ],
                    "type": "custom",
                    "tokenizer": "whitespace"
                },
                "whitespace_analyzer": {
                    "filter": [
                        "lowercase",
                        "asciifolding"
                    ],
                    "type": "custom",
                    "tokenizer": "whitespace"
                },
                "autocomplete": {
                    "filter": [
                        "lowercase"
                    ],
                    "type": "custom",
                    "tokenizer": "standard"
                },
                "analyzer_startswith": {
                    "filter": [
                        "lowercase"
                    ],
                    "tokenizer": "keyword"
                }
            },
            "tokenizer": {
                "autosuggest_tokenizer": {
                    "type": "edge_ngram",
                    "min_gram": 2,
                    "max_gram": 10,
                    "token_chars": [
                        "letter",
                        "digit"
                    ]
                }
            }
        },
        "number_of_replicas": "1"

    }
},
"mappings": {
    "sample": {
        "_all": {
            "analyzer": "nGram_analyzer"
        },
        "properties": {
            "sample_description": {
                "type": "text",
                "fields": {
                    "keyword": {
                        "type": "keyword",
                        "ignore_above": 256
                    }
                }
            },
            "sample_type": {
                "type": "keyword",
                "index": true
            },
            "sample": {
                "type": "keyword",
                "index": true,
                "analyzer": "autocomplete",
                "search_analyzer": "analyzer_startswith"
            },
            "sample1": {
                "type": "keyword",
                "index": true,
                "analyzer": "autocomplete",
                "search_analyzer": "analyzer_startswith"
            }
        }
    }
}
}

但是我收到以下错误,请您帮我解决这个问题。

{
"error": {
    "root_cause": [{
            "type": "mapper_parsing_exception",
            "reason": "Mapping definition for [sample1] has unsupported parameters:  [search_analyzer : analyzer_startswith] [analyzer : autocomplete]"
        }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [sample]: Mapping definition for [sample1] has unsupported parameters:  [search_analyzer : analyzer_startswith] [analyzer : autocomplete]",
    "caused_by": {
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [sample1] has unsupported parameters:  [search_analyzer : analyzer_startswith] [analyzer : autocomplete]"
    }
},
"status": 400
 }

【问题讨论】:

  • 请注意,在 _all_ 上使用 ngram 分析器是不好的做法。这将导致创建过多的令牌。此外,all 在版本 6 中已弃用,因此请不要使用它。

标签: elasticsearch


【解决方案1】:

keyword 类型不支持分析器。将类型更改为text,您应该一切顺利。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-15
    • 1970-01-01
    • 2019-11-10
    • 1970-01-01
    • 2023-03-25
    • 2018-06-20
    • 1970-01-01
    相关资源
    最近更新 更多