Skip to content

Instantly share code, notes, and snippets.

@jprante
Created October 13, 2013 23:32
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 jprante/6968540 to your computer and use it in GitHub Desktop.
Save jprante/6968540 to your computer and use it in GitHub Desktop.
Synonym example with Elasticsearch
curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test/' -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"synonym" : {
"tokenizer" : "whitespace",
"filter" : ["synonym"]
}
},
"filter" : {
"synonym" : {
"type" : "synonym",
"synonyms" : [
"foo => bar"
]
}
}
}
}
},
"mappings" : {
"_default_": {
"properties" : {
"name" : {
"type" : "string",
"analyzer" : "synonym"
}
}
}
}
}
'
curl -XPUT 'localhost:9200/test/data/1' -d '
{
"name" : "foo"
}
'
curl -XGET 'localhost:9200/test/_refresh'
curl -XGET 'localhost:9200/test/data/_search?pretty' -d '
{
"query" : {
"match": {
"name": {
"query": "foo"
}
}
}
}'
curl -XGET 'localhost:9200/test/data/_search?pretty' -d '
{
"query" : {
"match": {
"name": {
"query": "bar"
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment