The mapping in index creation in elasticsearch across the mongodb river does not take effect

I am trying to index mongodb in elasticsearch using mongodb-river using the following command, but the display of the document does not take effect. It still uses a standard parser (standard) for the text field

Mongoba River The document defines the creation of the index, but there is no documentation on how to provide custom mapping. This is what I tried. Is there any other documentation where I can find how to specify user parsers, etc. Using the mongodb river.

 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", "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 } } } }, "autocompleteindex": { "_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" } } } }' 

The query returns the correct results - this is a full word search, but does not match the substring. In addition, the gain does not show its effect.

What am I doing wrong?

+7
source share
1 answer

You need to first create your index using the index parameters (analyzer):

 "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 } } } 

Then you can define a mapping for your type:

 "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" } } } 

And only then can you create a river:

 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"} } 

Does it help?

+8
source

All Articles