# How to increase the speed of response?

**URL:** <https://discuss.elastic.co/t/how-to-increase-the-speed-of-response/366190>\
**Category:** Elasticsearch\
**Created:** [September 7, 2024, 2:13pm UTC](https://discuss.elastic.co/t/how-to-increase-the-speed-of-response/366190 "2024-09-07T14:13:08Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![octavian-nita](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/octavian-nita/32/67043_2.png) [@octavian-nita](https://discuss.elastic.co/u/octavian-nita)\
**Post date:** [September 11, 2024, 9:21am UTC](https://discuss.elastic.co/t/how-to-increase-the-speed-of-response/366190/22 "2024-09-11T09:21:09Z")

</div>

While better hardware will undoubtedly help, I fully endorse (based on personal experience) finding alternatives to the `wildcard` query for **partial** string/substring matching, which can quickly become slow and otherwise resource-intensive, especially when using _ **leading wildcards** _.

Among options:

1. If you _need_ to use wildcard queries, consider using the `wildcard` type for those fields that you query (assuming you don't query the whole `_source` and that you're using Elasticsearch v7.9 or later); see [Find strings within strings faster with the Elasticsearch wildcard field | Elastic Blog](https://www.elastic.co/blog/find-strings-within-strings-faster-with-the-new-elasticsearch-wildcard-field) for a nice intro. It's important to note that you need to _ **reindex** _ your dataset for these changes to take effect.
2. Use `fuzzy` queries; I have yet to use them myself, so I don't have any experience with them, but they can prove slow for large datasets, and adjusting the `fuzziness` attribute value could help balance accuracy and performance.
3. Use `match` queries and _ **custom analyzers** _ to index fields as _**(edge-)N-grams**_; this is likely one of the most convenient solutions; you can use the analyze API ([Test an analyzer | Elasticsearch Guide [8.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/test-analyzer.html)) to test your analyzers. You also need to reindex your dataset. Watch out for situations where your indexing results in an abundance of tokens due to the extensive character count (e.g., min\_gram=2, max\_gram=10); you can eventually mitigate by using n-gram with a low min\_gram - max\_gram range (e.g., 3 to 10 characters) or adding a search-as-you-type field.

In any case, you should thoroughly analyze the requirements to fine-tune the analyzers and queries—maybe not all fields need to be indexed, etc.

Additional resources:

- [Elasticsearch Query Partial Match](https://opster.com/guides/elasticsearch/how-tos/elasticsearch-query-partial-match)
- [Guidance on partial keyword search](https://discuss.elastic.co/t/guidance-on-partial-keyword-search/351094)

Good luck!

---

_[View the full topic](https://discuss.elastic.co/t/how-to-increase-the-speed-of-response/366190)._
