Trying to get a fuzziness example to work

Hi,
I'm trying to follow the example for fuzziness given here against the sample bank index. Here's the query:

GET /bank/_search?q=employer:Qu~

It returns nothing, but I expect to get 2 records, at least, from what I see from the data on my screen.

Thanks in advance to all who respond.

This is hard to say without looking at the sample data, but take this as an example.

PUT test/_doc/1
{
  "firstname" :"Alexander"
}

GET test/_search
{
  "query": {
    "query_string": {
      "default_field": "firstname",
      "query": "Alexandel~"
    }
  }
}

# no results
GET test/_search
{
  "query": {
    "query_string": {
      "default_field": "firstname",
      "query": "Alex~"
    }
  }
}

# same in URL
GET test/_search?q=firstname:Alexandel~

GET test/_search?q=firstname:Alex~

Keep in mind that fuzzy search is not a prefix search but it is about edit distance.

hope this helps.

1 Like

Hi, Alexander - thanks for the information. I tried your example in my Kibana console and it worked exactly as you described. However, when I tried to apply it to data in my index, I never get any hits. I basically copied your REST calls and changed the field to be one in my mapping; data in that field has text like "line" so I put in "lint~" and that did not work. There are lots of other examples in the documentation which don't work for some reason in my environment, most importantly the filter code. But that is a separate issue that I posted elsewhere in this forum. Thanks for your help!

Hey,

that is entirely possible due to a different mapping. Can you share a fully reproducible example that includes index and mapping creation, so we can take a look?

Thanks!

--Alex

Hi, Alex -

Unfortunately, due to the nature of my work, that is impossible. My interest in this is purely academic; I'm new to ES and was tasked with an ES effort, so I am trying to learn as much as I can about what's possible with the different language features so that I can address customer needs more effectively, should needs beyond the current scope of our capabilities arise. Thank you for your help nonetheless.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.