Skip to content

Instantly share code, notes, and snippets.

@jprante
Created June 5, 2012 22:26
Show Gist options
  • Save jprante/2878522 to your computer and use it in GitHub Desktop.
Save jprante/2878522 to your computer and use it in GitHub Desktop.
Synonyms
syn-setup.json:
{
"settings": {
"index" : {
"analysis" : {
"analyzer" : {
"synonym" : {
"tokenizer" : "whitespace",
"filter" : ["synonym"]
}
},
"filter" : {
"synonym" : {
"type" : "synonym",
"synonyms" : [
"OCallaghan, O'Callaghan"
]
}
}
}
}
}
}
curl -XDELETE 'localhost:9200/test/'
curl -XPUT 'localhost:9200/test/' --data-binary @syn-setup.json
curl -XGET "localhost:9200/test/_analyze?pretty&text=O'Callaghan&analyzer=synonym"
{
"tokens" : [ {
"token" : "OCallaghan",
"start_offset" : 0,
"end_offset" : 11,
"type" : "SYNONYM",
"position" : 1
}, {
"token" : "O'Callaghan",
"start_offset" : 0,
"end_offset" : 11,
"type" : "SYNONYM",
"position" : 1
} ]
}
curl -XGET "localhost:9200/test/_analyze?pretty&text=OCallaghan&analyzer=synonym"
{
"tokens" : [ {
"token" : "OCallaghan",
"start_offset" : 0,
"end_offset" : 10,
"type" : "SYNONYM",
"position" : 1
}, {
"token" : "O'Callaghan",
"start_offset" : 0,
"end_offset" : 10,
"type" : "SYNONYM",
"position" : 1
} ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment