小编use*_*398的帖子

使用映射创建Elasticsearch索引

我正在努力完成索引创建的简单任务,目标是使用分析器和字段映射创建索引.当我使用分析器创建索引时,我可以通过analyze api调用与分析器通信,但是当我添加映射信息时,创建索引调用失败,并且"找不到分析器[analyzer1]为字段[$ field]]",I创建了一个脚本来显示问题:

    #!/bin/bash

    INDEX_NAME="test1"

    echo "delete index just to be sure"
    curl -XDELETE "http://localhost:9200/$INDEX_NAME/"; echo

    echo "create new index"
    curl -X PUT "http://localhost:9200/$INDEX_NAME/" -d '{
        "index":{
            "analysis":{
                "analyzer":{
                    "analyzer1":{
                        "type":"custom",
                        "tokenizer":"standard",
                        "filter":[ "standard", "lowercase", "stop", "kstem", "ngram" ]
                    }
                },
                "filter":{
                    "ngram":{
                        "type":"ngram",
                        "min_gram":2,
                        "max_gram":15
                    }
                }
            }
        }
    }'; echo

    echo "analyze something with our shiny new analyzer"
    curl -XGET "localhost:9200/$INDEX_NAME/_analyze?analyzer=analyzer1&pretty=true" -d 'abcd'

    echo "remove the created index"
    curl -XDELETE "http://localhost:9200/$INDEX_NAME/"; echo

    echo "create new index again with …
Run Code Online (Sandbox Code Playgroud)

elasticsearch

15
推荐指数
1
解决办法
4万
查看次数

标签 统计

elasticsearch ×1