Skip to content

Instantly share code, notes, and snippets.

@andreluiz1987
Created August 8, 2022 00:29
Show Gist options
  • Save andreluiz1987/3704f2c6d28ea11caccad1e789c9e25b to your computer and use it in GitHub Desktop.
Save andreluiz1987/3704f2c6d28ea11caccad1e789c9e25b to your computer and use it in GitHub Desktop.
POST test/_doc
{
"category_suggest": {
"input": [
"Automotive",
"Auto"
]
}
}
POST test/_doc
{
"category_suggest": {
"input": [
"Automotive",
"Car"
]
}
}
GET test/_search
{
"_source": false,
"suggest": {
"suggestions": {
"prefix": "aut",
"completion": {
"field": "category_suggest",
"size": 5,
"skip_duplicates": false
}
}
}
}
DELETE test
PUT test
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"autocomplete_analyzer": {
"type": "custom",
"tokenizer": "standard",
"filter": [
"lowercase"
]
}
}
}
}
},
"mappings": {
"properties": {
"name": {
"type": "text"
},
"category": {
"type": "text"
},
"category_suggest": {
"type": "completion",
"analyzer": "autocomplete_analyzer"
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment