# There are some problems in my NEST Client search, can you help me solve it?

**URL:** <https://discuss.elastic.co/t/there-are-some-problems-in-my-nest-client-search-can-you-help-me-solve-it/240129>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [July 7, 2020, 9:12am UTC](https://discuss.elastic.co/t/there-are-some-problems-in-my-nest-client-search-can-you-help-me-solve-it/240129 "2020-07-07T09:12:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wajika](https://avatars.discourse-cdn.com/v4/letter/w/977dab/32.png) [@wajika](https://discuss.elastic.co/u/wajika)\
**Post date:** [July 7, 2020, 9:12am UTC](https://discuss.elastic.co/t/there-are-some-problems-in-my-nest-client-search-can-you-help-me-solve-it/240129/1 "2020-07-07T09:12:06Z")

</div>

1. I need to find the log with jobid xxx, but the result is different every time after running the following code;
2. I want to use the CreateTime field in reverse order, the following code is not successful;
3. I want to implement fuzzy query, but did not understand the example of elastic docs;

Please help me point out the problem in the code,thanks

> var searchResponse = await client.SearchAsync \< JobElasticDto \> (w =\>  
> w.Query(q =\> q  
> .Match(m =\> m  
> .Field(f =\> f  
> .JobInfoId)  
> .Query(input.JobId.ToString())  
> )  
> )  
> .From(input.SkipCount)  
> .Size(input.MaxResultCount)  
> .Sort(w =\> w.Descending(p =\> p.CreateTime))  
> .Query(w =\>  
> {  
> if(!string.IsNullOrEmpty(input.SourceType))  
> {  
> return w.Match(p =\> p.Field(q =\> q.SourceType == input.SourceType));  
> }  
> return null;  
> }).Query(w =\>  
> {  
> if(!string.IsNullOrEmpty(input.Keywords))  
> {  
> return w.Match(p =\> p.Field(q =\> q.Message.Contains(input.Keywords)));  
> }  
> return null;  
> }));

---

<div class="post-metadata">

**Author:** ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)\
**Post date:** [July 13, 2020, 7:15am UTC](https://discuss.elastic.co/t/there-are-some-problems-in-my-nest-client-search-can-you-help-me-solve-it/240129/2 "2020-07-13T07:15:46Z")

</div>

Please format your code, logs or configuration files using `</>` icon as explained in [this guide](https://discuss.elastic.co/t/about-the-elasticsearch-category/21) and not the citation button. It will make your post more readable.

Or use markdown style like:

````
```
CODE
```

````

This is the icon to use if you are not using markdown format:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e6e239431ec2d71cbf1beef741f2e93e7cc762c.jpg)

* * *

It looks like `.Query(...)` is being called multiple times. This call is assignative and not additive, so the last call assigns and replaces any previous assignments. To combine queries into a compound `bool` query, take a look at the [writing queries](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/writing-queries.html#combining-queries) and [writing bool queries](https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/bool-queries.html) documentation.

---

<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:** [August 10, 2020, 7:15am UTC](https://discuss.elastic.co/t/there-are-some-problems-in-my-nest-client-search-can-you-help-me-solve-it/240129/3 "2020-08-10T07:15:53Z")

</div>

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