# Which search to use for a custom site search

**URL:** <https://discuss.elastic.co/t/which-search-to-use-for-a-custom-site-search/173048>\
**Category:** Elasticsearch\
**Created:** [March 19, 2019, 7:58pm UTC](https://discuss.elastic.co/t/which-search-to-use-for-a-custom-site-search/173048 "2019-03-19T19:58:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [March 19, 2019, 7:58pm UTC](https://discuss.elastic.co/t/which-search-to-use-for-a-custom-site-search/173048/1 "2019-03-19T19:58:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![glenacota](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/glenacota/32/41367_2.png) [@glenacota](https://discuss.elastic.co/u/glenacota)\
**Post date:** [March 19, 2019, 9:33pm UTC](https://discuss.elastic.co/t/which-search-to-use-for-a-custom-site-search/173048/2 "2019-03-19T21:33:46Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/6.6/common-options.html#fuzziness), you'll see that when you set the `fuzziness` parameter to `AUTO`, then only two edits are allowed (e.g., T`o`m, or T`ee`m will match, but Tim`othy` has an edit distance of four and won't match).

---

<div class="post-metadata">

**Author:** ![mc1392](https://avatars.discourse-cdn.com/v4/letter/m/57b2e6/32.png) [@mc1392](https://discuss.elastic.co/u/mc1392)\
**Post date:** [March 20, 2019, 3:36pm UTC](https://discuss.elastic.co/t/which-search-to-use-for-a-custom-site-search/173048/3 "2019-03-20T15:36:57Z")

</div>

@glenacota Thanks for the info!

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 20, 2019, 4:07pm UTC](https://discuss.elastic.co/t/which-search-to-use-for-a-custom-site-search/173048/4 "2019-03-20T16:07:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 17, 2019, 4:07pm UTC](https://discuss.elastic.co/t/which-search-to-use-for-a-custom-site-search/173048/5 "2019-04-17T16:07:30Z")

</div>

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