Skip to content

Instantly share code, notes, and snippets.

@cbuescher
Created March 3, 2022 15:04
Show Gist options
  • Save cbuescher/ad3fef4cfd4889afcb8e8779e300b08c to your computer and use it in GitHub Desktop.
Save cbuescher/ad3fef4cfd4889afcb8e8779e300b08c to your computer and use it in GitHub Desktop.
Simple synonym example
DELETE test
PUT /test
{
"settings": {
"index": {
"analysis": {
"analyzer": {
"synonym": {
"tokenizer": "standard",
"filter": [ "synonym" ]
}
},
"filter": {
"synonym": {
"type": "synonym",
"lenient": true,
"synonyms": [ "car, automobile, vehicle" ]
}
}
}
}
},
"mappings": {
"properties": {
"message" : {
"type": "text",
"analyzer": "standard",
"search_analyzer": "synonym"
}
}
}
}
PUT /test/_doc/1
{
"message" : "This is a fast car."
}
POST /test/_search
{
"query": {
"match": {
"message": "vehicle"
}
}
}
POST /test/_search
{
"query": {
"match": {
"message": "automobile"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment