Created
May 8, 2011 15:15
-
-
Save hukl/961418 to your computer and use it in GitHub Desktop.
Sample ElasticSearch session for ngram
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
Settings: | |
curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1' -d ' | |
{ | |
"settings" : { | |
"analysis" : { | |
"filter" : { | |
"edge_ngram" : { | |
"side" : "front", | |
"max_gram" : 20, | |
"min_gram" : 1, | |
"type" : "edgeNGram" | |
} | |
}, | |
"analyzer" : { | |
"ascii_ngram" : { | |
"filter" : [ | |
"standard", | |
"lowercase", | |
"asciifolding", | |
"nGram" | |
], | |
"type" : "custom", | |
"tokenizer" : "standard" | |
}, | |
"ascii_std" : { | |
"filter" : [ | |
"standard", | |
"lowercase", | |
"asciifolding" | |
], | |
"type" : "custom", | |
"tokenizer" : "standard" | |
}, | |
"ascii_edge_ngram" : { | |
"filter" : [ | |
"standard", | |
"lowercase", | |
"asciifolding", | |
"edge_ngram" | |
], | |
"type" : "custom", | |
"tokenizer" : "standard" | |
} | |
} | |
} | |
} | |
} | |
' | |
{ | |
"ok" : true, | |
"acknowledged" : true | |
} | |
Mapping: | |
curl -XPUT 'http://127.0.0.1:9200/test/website/_mapping?pretty=1' -d ' | |
{ | |
"website" : { | |
"properties" : { | |
"uri" : { | |
"type" : "string", | |
"include_in_all" : 0, | |
"index_analyzer" : "ascii_ngram", | |
"search_analyzer" : "ascii_std" | |
} | |
} | |
} | |
} | |
' | |
{ | |
"ok" : true, | |
"acknowledged" : true | |
} | |
Inserting Doc: | |
curl -XPOST 'http://127.0.0.1:9200/test/website?pretty=1' -d ' | |
{ | |
"uri" : "http://www.heise.de" | |
} | |
' | |
{ | |
"ok" : true, | |
"_index" : "test", | |
"_type" : "website", | |
"_id" : "4ZmkqRU5QSynba8ta2gOSQ", | |
"_version" : 1 | |
} | |
Query: | |
curl -XGET 'http://127.0.0.1:9200/test/website/_search?pretty=1' -d ' | |
{ | |
"query" : { | |
"field" : { | |
"uri" : "heis" | |
} | |
} | |
} | |
' | |
{ | |
"took" : 2, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 5, | |
"successful" : 5, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 0, | |
"max_score" : null, | |
"hits" : [ ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment