Last active
October 11, 2020 23:36
-
-
Save bojidaryovchev/a0c908ef3f1eb0ea68ea032ac42b4e38 to your computer and use it in GitHub Desktop.
Mongoose Mongoosastic ElasticSearch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mongoosastic | |
mongoose.model('product', ProductSchema); | |
PUT http://localhost:9200/products | |
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"autocomplete": { | |
"tokenizer": "autocomplete", | |
"filter": [ | |
"lowercase" | |
] | |
}, | |
"autocomplete_search": { | |
"tokenizer": "lowercase" | |
} | |
}, | |
"tokenizer": { | |
"autocomplete": { | |
"type": "edge_ngram", | |
"min_gram": 2, | |
"max_gram": 20, | |
"token_chars": [ | |
"letter", "digit", "whitespace" | |
] | |
} | |
} | |
} | |
} | |
} | |
PUT http://localhost:9200/products/product/_mapping | |
{ | |
"properties": { | |
"value": { | |
"type": "text", | |
"analyzer": "autocomplete", | |
"search_analyzer": "autocomplete_search" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment