# Wildcard query using NEST API

**URL:** <https://discuss.elastic.co/t/wildcard-query-using-nest-api/375867>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [March 13, 2025, 10:13pm UTC](https://discuss.elastic.co/t/wildcard-query-using-nest-api/375867 "2025-03-13T22:13:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xef](https://avatars.discourse-cdn.com/v4/letter/x/898d66/32.png) [@xef](https://discuss.elastic.co/u/xef)\
**Post date:** [March 13, 2025, 10:13pm UTC](https://discuss.elastic.co/t/wildcard-query-using-nest-api/375867/1 "2025-03-13T22:13:11Z")

</div>

We have the following Wildcard query.  
What we want to do is if the query matches the beginning then it should be boosted to the top. All results should be in Ascending alphabetic order based on the field "Name" which is the target of the query for those that begin with the prefix and thoose that have the refix within their name.

```auto
var searchResponse = client.Search<Locality>(s => s
                    .Index(index)
                    .Size(100)
                    
                    .Query(ss => ss
                        .Wildcard(c => c
                        .Name("named_query")
                        .Boost(1.1)
                        .Field(p => p.Name)
                        .Value($"*{prefix}*")
                        .CaseInsensitive(true)
                        )
                );

```

---

<div class="post-metadata">

**Author:** ![flobernd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flobernd/32/124877_2.png) [@flobernd](https://discuss.elastic.co/u/flobernd)\
**Post date:** [March 14, 2025, 8:01am UTC](https://discuss.elastic.co/t/wildcard-query-using-nest-api/375867/2 "2025-03-14T08:01:34Z")

</div>

Hi @xef ,

just to clarify: Are you using NEST (7.x) or `Elastic.Clients.Elasticsearch` (8.x)?

Besides that, could you please clarify your question? It's not clear to me whether you need assistance with the client syntax or general assistance to achieve this specific goal with Elasticsearch in the first place.

Do you, for example, have a equivalent REST JSON request that we can translate to the client syntax?

---

<div class="post-metadata">

**Author:** ![xef](https://avatars.discourse-cdn.com/v4/letter/x/898d66/32.png) [@xef](https://discuss.elastic.co/u/xef)\
**Post date:** [March 14, 2025, 8:57pm UTC](https://discuss.elastic.co/t/wildcard-query-using-nest-api/375867/3 "2025-03-14T20:57:25Z")

</div>

Thanks for responding.  
As outlined, we would like to create a query such as the one mentioned using a wildcard and returning the ones that start with the query first and then the rest that do not start with the query but have the qery within.

We are using NEST 7.

It is not just the syntax but also the actual query itself. How it should be formed and sorted in order to achieve the desired result.  
Thanks
