This is how I set up the mappings: curl -s -XPUT 'localhost:9200/test' -d '{ "mappings": { "properties": { "name": { "street": { "type": "string", "index_analyzer": "index_ngram", "search_analyzer": "search_ngram" } } } }, "settings": { "analysis": { "filter": { "desc_ngram": { "type": "edgeNGram", "min_gram": 3, "max_gram": 20 } }, "analyzer": { "index_ngram": { "type": "custom", "tokenizer": "keyword", "filter": [ "desc_ngram", "lowercase" ] }, "search_ngram": { "type": "custom", "tokenizer": "keyword", "filter": "lowercase" } } } } }'
This is how I built the index: curl -s -XPUT 'localhost:9200/test/name/1' -d '{ "street": "Lakeshore Dr" }' curl -s -XPUT 'localhost:9200/test/name/2' -d '{ "street": "Sunnyshore Dr" }' curl -s -XPUT 'localhost:9200/test/name/3' -d '{ "street": "Lake View Dr" }' curl -s -XPUT 'localhost:9200/test/name/4' -d '{ "street": "Shore Dr" }' If a user attempts to search for "Lake Shore Dr", I want to only match to document 1/"Lakeshore Dr" If a user attempts to search for "Lakeview Dr", I want to only match to document 3/"Lake View Dr" Here is an example of the query that is not working correctly: curl -s -XGET 'localhost:9200/test/_search?pretty=true' -d '{ "query":{ "bool":{ "must":[ { "match":{ "street":{ "query":"lake shore dr", "type":"boolean" } } } ] } } }'; So is the issue with how I am setting up the mappings (tokenizer?, edgegram vs ngrams?, size of ngrams?) or the query (I have tried things like setting the minimum_should_match, and the analyzer to use), but I have not been able to get the desired results. Thanks all. On Thursday, February 6, 2014 10:16:40 AM UTC-5, Binh Ly wrote: > > Thale, you are correct - ngrams are usually used at index-time only, but > in your case and requirements, you might want to experiment both index and > seach time. I'd probably just increase the edge min ngram size to something > reasonable like maybe 4(?) and see if that works or not. > -- You received this message because you are subscribed to the Google Groups "elasticsearch" group. To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3b7a9d63-3a08-4cfc-96ce-4b22d44cd9db%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.