Elasticsearch index creation with mapping

后端 未结 1 1103
一整个雨季
一整个雨季 2021-02-02 14:40

I\'m struggling with the simple task of index creation, the goal is to create an index with an analyzer and a field mapping. When I create a index with an analyzer i can talk to

相关标签:
1条回答
  • 2021-02-02 15:43

    I believe your issue is that the analysis settings need to be nested within a settings node in your JSON, not within an index node as you have it. Please reference the Elasticsearch Create Index API for details on constructing the JSON.

    Therefore, your create index call should look like the the following:

    curl -X PUT "http://localhost:9200/$INDEX_NAME/" -d '{
        "settings":{
            "analysis":{
                "analyzer":{
                    "analyzer1":{
                        "type":"custom",
                        "tokenizer":"standard",
                        "filter":[ "standard", "lowercase", "stop", "kstem", "ngram" ]
                    }
                },
                "filter":{
                    "ngram":{
                        "type":"ngram",
                        "min_gram":2,
                        "max_gram":15
                    }
                }
            }
        },
        "mappings": {
            "product": {
                "properties": {
                    "title": {
                        "type": "string",
                        "search_analyzer" : "analyzer1",
                        "index_analyzer" : "analyzer1"
                    }
                }
            }
        }
    }';
    
    0 讨论(0)
提交回复
热议问题