Skip to content

Instantly share code, notes, and snippets.

@dadoonet
Created January 16, 2014 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dadoonet/8456535 to your computer and use it in GitHub Desktop.
Save dadoonet/8456535 to your computer and use it in GitHub Desktop.
{
"took" : 62,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 0.53148466,
"hits" : [ {
"_index" : "listings",
"_type" : "homes",
"_id" : "3",
"_score" : 0.53148466, "_source" : { "desc": "A colonial mansion with a large yard and a pool." }
} ]
}
}
curl -s -XDELETE 'localhost:9200/listings'
curl -s -XPUT 'localhost:9200/listings' -d '{
"mappings": {
"homes": {
"properties": {
"desc": {
"type": "string",
"index_analyzer": "index_ngram",
"search_analyzer": "search_ngram"
}
}
}
},
"settings": {
"analysis": {
"filter": {
"desc_ngram": {
"type": "ngram",
"min_gram": 3,
"max_gram": 8
}
},
"analyzer": {
"index_ngram": {
"type": "custom",
"tokenizer": "keyword",
"filter": [ "desc_ngram", "lowercase" ]
},
"search_ngram": {
"type": "custom",
"tokenizer": "keyword",
"filter": "lowercase"
}
}
}
}
}'
curl -s -XPUT 'localhost:9200/listings/homes/1' -d '{ "desc": "This is a lovely home with a large yard." }'
curl -s -XPUT 'localhost:9200/listings/homes/2' -d '{ "desc": "This large fixer-upper has a gravelly yard." }'
curl -s -XPUT 'localhost:9200/listings/homes/3?refresh' -d '{ "desc": "A colonial mansion with a large yard and a pool." }'
curl -s -XGET 'localhost:9200/listings/homes/_search?pretty=true' -d '{
"query":{
"bool":{
"must":[
{
"match":{
"desc":{
"query":"large ya",
"type":"phrase"
}
}
},
{
"match":{
"desc":{
"query":"arge yar",
"type":"phrase"
}
}
},
{
"match":{
"desc":{
"query":"rge yard",
"type":"phrase"
}
}
}
]
}
}
}';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment