Created
January 16, 2014 15:13
-
-
Save dadoonet/8456535 to your computer and use it in GitHub Desktop.
Testing ngrams
for https://groups.google.com/d/msgid/elasticsearch/4bee1be0-7ee4-4667-b4f7-b51371963928%40googlegroups.com
This file contains hidden or 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
{ | |
"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." } | |
} ] | |
} | |
} |
This file contains hidden or 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
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