Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elastic search fuzziness in query_string

I'm specifying a fuzzy_prefix_length in the query string, but a search for "tes" is not pulling up posts that are titled "test" ... any ideas what I'm doing wrong?

this is my query string setup

"query" : {
  "query_string" : {
    "query" : the-query-string-goes-here,
    "default_operator" : "AND",
    "fuzzy_prefix_length" : 3,
  }
}
like image 245
concept47 Avatar asked Sep 16 '12 04:09

concept47


People also ask

What is fuzziness in Elasticsearch?

Fuzzy queryedit. Returns documents that contain terms similar to the search term, as measured by a Levenshtein edit distance. An edit distance is the number of one-character changes needed to turn one term into another.

How do I search for a query in Elasticsearch?

You can use the search API to search and aggregate data stored in Elasticsearch data streams or indices. The API's query request body parameter accepts queries written in Query DSL. The following request searches my-index-000001 using a match query. This query matches documents with a user.id value of kimchy .

What is Query String Elasticsearch?

In Elasticsearch, query string queries are their own breed of query - loads of functionality for full text search rolled into one sweet little package. In this article, we'll take a closer look at why query string queries are special and how you can make use of them.

What is the role of query string in web communication write an example for a query string?

A query string commonly includes fields added to a base URL by a Web browser or other client application, for example as part of an HTML, choosing the appearance of a page, or jumping to positions in multimedia content.


1 Answers

You are, probably, missing "fuzzy" operator at the end of the query. Try this:

"query" : {
  "query_string" : {
    "query" : "tes~",
    "default_operator" : "AND",
    "fuzzy_prefix_length" : 3,
  }
}
like image 175
imotov Avatar answered Dec 28 '22 14:12

imotov