# How to match by different prefixes

**URL:** <https://discuss.elastic.co/t/how-to-match-by-different-prefixes/284104>\
**Category:** Elasticsearch\
**Created:** [September 13, 2021, 4:01pm UTC](https://discuss.elastic.co/t/how-to-match-by-different-prefixes/284104 "2021-09-13T16:01:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mydeadvictoria](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mydeadvictoria/32/93843_2.png) [@mydeadvictoria](https://discuss.elastic.co/u/mydeadvictoria)\
**Post date:** [September 13, 2021, 4:01pm UTC](https://discuss.elastic.co/t/how-to-match-by-different-prefixes/284104/1 "2021-09-13T16:01:14Z")

</div>

Will try to explain what I mean by saying "different prefixes". I have a text field "Name", and I want to check (while searching) whether this field starts with some particular prefix with length varying from 3 to 5.

Let's say `Name = "Anna K"`. And the name in query is "Ann Blake". I want the name to match the previous query. So the idea here is that only first five characters are considered.

Name in the record can be any length, but I need to take into account only up to 5 characters (from 3 to 5 actually).

I'm not sure how to implement this. I've added an edge-ngram analyzer to my field. Now, what next?

I can't access analyzed n-grams directly afaik. So for example, I can't match against `Name.3ngram`, `Name.4ngram`, `Name.5ngram`, can I?

---

<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:** [October 11, 2021, 4:01pm UTC](https://discuss.elastic.co/t/how-to-match-by-different-prefixes/284104/2 "2021-10-11T16:01:15Z")

</div>

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