Created
January 28, 2013 10:38
-
-
Save jprante/4654514 to your computer and use it in GitHub Desktop.
Demonstration of Beider-Morse phonetic filter with Elasticsearch
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
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