Skip to content

Instantly share code, notes, and snippets.

@polyfractal
Last active August 29, 2015 14:27
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 polyfractal/1a6d61a56a0267fb5651 to your computer and use it in GitHub Desktop.
Save polyfractal/1a6d61a56a0267fb5651 to your computer and use it in GitHub Desktop.
PUT /syn
{
"index": {
"analysis": {
"analyzer": {
"synonym": {
"tokenizer": "standard",
"filter": [
"synonym"
]
}
},
"filter": {
"synonym": {
"type": "synonym",
"synonyms": [
"apple, orange, fruit",
"smoothie, shake, milkshake"
]
}
}
}
}
}
POST /syn/test/
{
"title": "apple healthy smoothie"
}
POST /syn/test/
{
"title": "apple healthy nutty super great more than 3 tokens smoothie"
}
GET /syn/test/_search
{
"query": {
"match": {
"title": {
"type": "phrase",
"query": "orange milkshake",
"slop": 3,
"analyzer": "synonym"
}
}
}
}
GET /syn/test/_search
{
"query": {
"match": {
"title": {
"type": "phrase",
"query": "fruit shake",
"slop": 3,
"analyzer": "synonym"
}
}
}
}
//Note that if you omit the analyzer (and use the default),
//it won't find anything since the synonyms are not indexed
GET /syn/test/_search
{
"query": {
"match": {
"title": {
"type": "phrase",
"query": "fruit shake",
"slop": 3
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment