Skip to content

Instantly share code, notes, and snippets.

@xeraa
Created February 26, 2019 05:07
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 xeraa/981244dcc22af67cd09e0c4de072a602 to your computer and use it in GitHub Desktop.
Save xeraa/981244dcc22af67cd09e0c4de072a602 to your computer and use it in GitHub Desktop.
Synonym graph in Elasticsearch with an updated synonym list
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