Which search to use for a custom site search

I am planning on creating a site search.

Which search do you recommend? It gets a bit confusing with so many options.
I'd like to take the values from an HTML form input field and perform some fuzzy matching, across all fields in my index.

Those fields will probably be:

  • Page Title
  • Category
  • URL

This is what I'm currently using for a separate search, for firstname and lastname.

MatchQueryBuilder matchFirstname = new MatchQueryBuilder("firstname", firstname).fuzziness(Fuzziness.AUTO);
MatchQueryBuilder matchLastname = new MatchQueryBuilder("lastname", lastname).fuzziness(Fuzziness.AUTO);
BoolQueryBuilder qb = boolQuery().must(matchFirstname).must(matchLastname);
SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
sourceBuilder.query(qb);
SearchRequest searchRequest = new SearchRequest(indexName);
searchRequest.source(sourceBuilder);

This current search does not provide any fuzziness. When I search for "Tim"(firstname) and "Brow" (lastname) I am not getting "Timothy Brownlee" returned as one of the records, when I should.

Any ideas on how to approach this and why my Fuzziness is not working as I hope?

As for you question on Fuzziness, it looks correct to me that you're not getting Timothy from Tim. If you look at the relevant documentation, you'll see that when you set the fuzziness parameter to AUTO, then only two edits are allowed (e.g., Tom, or Teem will match, but Timothy has an edit distance of four and won't match).

1 Like

@glenacota Thanks for the info!

I switched fuzziness to 8, still I don't get the results I am expecting.

The maximum value is 2. After that, I don't think it really make sense. AUTO is the best compromise IMHO.

1 Like

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