您必须首先使用索引设置(分析器)创建索引:
"analysis" : { "analyzer" : { "str_search_analyzer" : {"tokenizer" : "keyword","filter" : ["lowercase"] }, "str_index_analyzer" : { "tokenizer" : "keyword", "filter" : ["lowercase", "ngram"] } }, "filter" : { "ngram" : { "type" : "ngram", "min_gram" : 2, "max_gram" : 20 } } }然后,您可以为您的类型定义一个映射:
"autocomplete_questions": { "_boost" : { "name" : "po", "null_value" : 1.0 }, "properties": { "po": { "type": "double" }, "text": { "type": "string", "boost": 3.0, "search_analyzer" : "str_search_analyzer", "index_analyzer" : "str_index_analyzer" } }}只有这样,您才能创建河流:
curl -XPUT "localhost:9200/_river/autocompleteindex/_meta" -d '{"type": "mongodb","mongodb": { "host": "rahulg-dc", "port": "27017", "db": "qna", "collection": "autocomplete_questions"},"index": { "name": "autocompleteindex", "type": "autocomplete_questions"} }有帮助吗?



