Skip to content

Instantly share code, notes, and snippets.

@jprante
Created January 28, 2013 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jprante/4654514 to your computer and use it in GitHub Desktop.
Save jprante/4654514 to your computer and use it in GitHub Desktop.
Demonstration of Beider-Morse phonetic filter with Elasticsearch
curl -XDELETE 'localhost:9200/test'
# grasp available rules with: jar tvf plugins/analysis-phonetic/commons-codec-*.jar | grep bm
curl -XPUT 'localhost:9200/test' -d '
{
"settings" : {
"index" : {
"analysis" : {
"filter" : {
"beider_morse": {
"type" : "phonetic",
"encoder" : "beider_morse",
"languageset" : [ "french", "english", "german" ]
}
},
"analyzer" : {
"phoneticAnalyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "stemmer", "beider_morse"]
}
}
}
}
},
"mappings" : {
"_default_": {
"properties" : {
"nom" : {
"type" : "string",
"analyzer" : "phoneticAnalyzer"
},
"prenom" : {
"type" : "string",
"analyzer" : "phoneticAnalyzer"
}
}
}
}
}
'
curl -XPUT 'localhost:9200/test/data/1' -d '
{
"prenom" : "Yann",
"nom" : " Rimbault"
}
'
curl -XGET 'localhost:9200/test/_refresh'
curl -XGET 'localhost:9200/test/_analyze?analyzer=phoneticAnalyzer&text=yann'
echo
echo "Query 1"
echo
curl -XGET 'localhost:9200/test/data/_search?pretty' -d '
{
"query" : {
"text": {
"prenom": {
"query": "yann"
}
}
}
}'
curl -XGET 'localhost:9200/test/_analyze?analyzer=phoneticAnalyzer&text=yan'
echo
echo "Query 2"
echo
curl -XGET 'localhost:9200/test/data/_search?pretty' -d '
{
"query" : {
"text": {
"prenom": {
"query": "yan"
}
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment