Skip to content

Instantly share code, notes, and snippets.

@hlassiege
Last active December 16, 2015 05:19
Show Gist options
  • Save hlassiege/5383739 to your computer and use it in GitHub Desktop.
Save hlassiege/5383739 to your computer and use it in GitHub Desktop.
nGram test
curl -X DELETE localhost:9200/test
curl -X PUT localhost:9200/test -d '
{
"settings" : {
"index" : {
"analysis" : {
"analyzer" : {
"myanalyzer" : {
"type" : "custom",
"tokenizer" : "lowercase",
"filter" : ["stop", "myngram"]
}
},
"filter" : {
"myngram" : {
"type" : "nGram",
"min_gram" : 3,
"max_gram" : 5
}
}
}
}
},
"mappings": {
"entities": {
"properties": {
"entities": {
"type": "string",
"analyzer": "myanalyzer"
}
}
}
}
}
'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["playframework"] }'
Then, open on :
http://localhost:9200/test/entities/_search?q=entities:Play%20Framework
The result :
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.019487087,
"hits": [
{
"_index": "test",
"_type": "entities",
"_id": "WjhCpN69SBKf3PZ--kDhog",
"_score": 0.019487087,
"_source": {
"entities": [
"playframework"
]
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment