Skip to content

Instantly share code, notes, and snippets.

@ogirardot
Forked from hlassiege/gist:5383739
Last active December 16, 2015 05:49
Show Gist options
  • Save ogirardot/5386898 to your computer and use it in GitHub Desktop.
Save ogirardot/5386898 to your computer and use it in GitHub Desktop.
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" : "edgeNGram",
"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"] }'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["actionscript"] }'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["postgresql"] }'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["django"] }'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["lift web"] }'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["lift"] }'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["scalatra"] }'
curl -X POST "http://localhost:9200/test/entities" -d '{ "entities" : ["sinatra"] }'
Then, open on :
http://localhost:9200/test/entities/_search?q=entities:Play%20Framework
The result is not :
{
"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"
]
}
}
]
}
}
but
{
"took": 13,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.4240102,
"hits": [
{
"_index": "test",
"_type": "entities",
"_id": "xQGL_dZ8QjanhGKu1ht19w",
"_score": 0.4240102,
"_source": {
"entities": [
"playframework"
]
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment