Skip to content

Instantly share code, notes, and snippets.

@bojidaryovchev
Last active October 11, 2020 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bojidaryovchev/a0c908ef3f1eb0ea68ea032ac42b4e38 to your computer and use it in GitHub Desktop.
Save bojidaryovchev/a0c908ef3f1eb0ea68ea032ac42b4e38 to your computer and use it in GitHub Desktop.
Mongoose Mongoosastic ElasticSearch
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