Created
February 26, 2019 05:07
-
-
Save xeraa/981244dcc22af67cd09e0c4de072a602 to your computer and use it in GitHub Desktop.
Synonym graph in Elasticsearch with an updated synonym list
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
PUT /test_index | |
{ | |
"settings": { | |
"index": { | |
"analysis": { | |
"analyzer": { | |
"synonym_analyzer": { | |
"tokenizer": "standard", | |
"filter": [ | |
"synonym_graph" | |
] | |
} | |
}, | |
"filter": { | |
"synonym_graph": { | |
"type": "synonym_graph", | |
"synonyms": [ | |
"foo, bar" | |
] | |
} | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"_doc": { | |
"properties": { | |
"quote": { | |
"type": "text", | |
"analyzer": "synonym_analyzer" | |
} | |
} | |
} | |
} | |
} | |
PUT /test_index/_doc/1 | |
{ | |
"quote": "foo" | |
} | |
POST /test_index/_search | |
{ | |
"query": { | |
"match": { | |
"quote": "bar" | |
} | |
} | |
} | |
POST /test_index/_close | |
PUT /test_index/_settings | |
{ | |
"analysis": { | |
"filter": { | |
"synonym_graph": { | |
"type": "synonym_graph", | |
"synonyms": [ | |
"foo, bar", | |
"foo, baz" | |
] | |
} | |
} | |
} | |
} | |
POST /test_index/_open | |
POST /test_index/_search | |
{ | |
"query": { | |
"match": { | |
"quote": "baz" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment