nest - elasticsearch query string not performing fuzzy query as expected when using phrases -
i'm not getting expected result when using phrase in query_string elasticsearch.
let's have title, 'john wayne goes manhattan'. i've indexed title field 'standard' analyzer , next query. or without fuzzy indicator (~) won't find unless have 'john wayne' spelled correctly. no results 'john wane' or similar.
"query": { "query_string": { "fields": ["title^2"], "query": "\"john wayne\"~1", "default_operator": "and", "phrase_slop": 0, "minimum_should_match": "100%" } } i've tried altering number after tilde increment fuziness, still no matches.
any ideas?
doing fuzzy search on phrase "proximity" search. instead of measuring levenshtein distance between letters, proximity between terms in query.
your query should homecoming results if were:
"query" : "john wane~1" see here more info on difference: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_fuzziness
edit:
here concrete illustration recreation:
create docs
curl -xput "http://localhost:9200/test/test/1" -d' { "message" : "my best friend john wayne, yours?" }' curl -xput "http://localhost:9200/test/test/2" -d' { "message" : "my best friend john marion wayne, yours?" }' curl -xput "http://localhost:9200/test/test/3" -d' { "message" : "my best friend john marion mitchell wayne, yours?" }' sample naive query, non phrase:
curl -xget "http://localhost:9200/_search" -d' { "query" : { "query_string": { "query": "john , wane~1" } } }' how phrase query span. notice terms lower cased, term query not analyzed. also, can adjust span slop command how close each other each term should be.
curl -xget "http://localhost:9200/_search" -d' { "query" : { "span_near" : { "clauses" : [ { "span_term" : { "message" : "john" } }, { "span_term" : { "message" : "wayne" } } ], "slop" : 0, "in_order" : true } } }' and here real deal of looking for.
curl -xget "http://localhost:9200/_search" -d' { "query" : { "span_near" : { "clauses" : [ { "span_multi" : { "match" : { "fuzzy" : { "message" : { "value" : "john", "fuzziness" : "1" } } } } }, { "span_multi" : { "match" : { "fuzzy" : { "message" : { "value" : "wane", "fuzziness" : "1" } } } } } ], "slop" : 0, "in_order" : true } } }' elasticsearch nest
No comments:
Post a Comment