Skip to content

Instantly share code, notes, and snippets.

@jprante
Created November 15, 2012 21:26
Show Gist options
  • Save jprante/4081391 to your computer and use it in GitHub Desktop.
Save jprante/4081391 to your computer and use it in GitHub Desktop.
analyzer test
curl -XDELETE 'http://localhost:9200/test'
curl -XPOST 'http://localhost:9200/test' -d '
{
"settings" : {
"index" : {
"analysis" : {
"filter": {
"eNGram" : {
"type": "edgeNGram",
"side" : "front",
"min_gram" : 1,
"max_gram" : 20
},
"stemmer" : {
"type" : "stemmer",
"name" : "english"
},
"wordDelimit" : {
"type" : "word_delimiter",
"generate_word_parts" : false,
"generate_number_parts": false,
"split_on_case_change": false,
"split_on_numerics" : false,
"stem_english_possessives": true
}
},
"analyzer" : {
"indexAnalyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "stemmer", "wordDelimit"]
},
"searchAnalyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : ["standard", "lowercase", "stemmer", "wordDelimit"]
},
"orderedPartialMatch" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : ["lowercase", "stemmer", "wordDelimit", "eNGram"]
}
}
}
}
},
"mappings" : {
"_default_" : {
"properties" : {
"name" : {
"type" : "multi_field",
"fields" : {
"name" : {
"type" : "string",
"include_in_all" : true,
"boost" : 2.0,
"index" : "analyzed",
"index_analyzer" : "indexAnalyzer",
"search_analyzer" : "searchAnalyzer"
},
"name_partial" : {
"type" : "string",
"include_in_all" : true,
"boost" : 6.0,
"index" : "analyzed",
"index_analyzer" : "orderedPartialMatch",
"search_analzer" : "searchAnalyzer"
},
"name_full" : {
"type" : "string",
"include_in_all" : true,
"boost" : 10.0,
"index" : "not_analyzed"
}
}
}
}
}
}
}
'
curl -XPUT 'localhost:9200/test/test/1' -d "
{
\"name\" : \"Davidson's Collection\"
}
"
curl -XPUT 'localhost:9200/test/test/2' -d '
{
"name" : "Davidsons Collection"
}
'
curl -XPUT 'localhost:9200/test/test/3' -d '
{
"name" : "Davidson Collection"
}
'
curl -XGET 'localhost:9200/test/_refresh'
# search all docs
curl -XGET 'http://localhost:9200/test/_search?q=*&pretty=1'
# search for words
curl -XGET 'http://localhost:9200/test/_search?q=Davidson%27s+Collection&pretty=1'
curl -XGET 'http://localhost:9200/test/_search?q=Davidsons+Collection&pretty=1'
curl -XGET 'http://localhost:9200/test/_search?q=Davidson+Collection&pretty=1'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment