# How we can use Search Query in Elastic.Clients.Elasticsearch

**URL:** <https://discuss.elastic.co/t/how-we-can-use-search-query-in-elastic-clients-elasticsearch/347691>\
**Category:** Elasticsearch\
**Created:** [November 22, 2023, 5:02am UTC](https://discuss.elastic.co/t/how-we-can-use-search-query-in-elastic-clients-elasticsearch/347691 "2023-11-22T05:02:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jahanzaib](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jahanzaib/32/122308_2.png) [@Jahanzaib](https://discuss.elastic.co/u/Jahanzaib)\
**Post date:** [November 22, 2023, 5:02am UTC](https://discuss.elastic.co/t/how-we-can-use-search-query-in-elastic-clients-elasticsearch/347691/1 "2023-11-22T05:02:43Z")

</div>

'''var response = await \_client.SearchAsync(s =\> s  
.Index("indici\_timeline\_death\_patient\_vector\_ml")  
.From(0)  
.Size(10)  
.Query(q =\> q  
.Bool(b =\> b  
.Must(m =\> m  
.Term(mu =\> mu.Field(f =\> f.patientid).Value(formData.PatientID)),  
m =\> m.Term(mu =\> mu.Field(f =\> f.practiceid).Value(formData.PracticeID)),  
m =\> m.Terms(ts =\> ts.Field("eventtypeid")  
.Terms(new Elastic.Clients.Elasticsearch.QueryDsl.TermsQueryField(formData.EventIDs.Select(id =\> FieldValue.Long(id)).ToArray())))  
)  
)  
)  
);  
}'''  
Here is my code. And i am using Elastic.Clients.Elasticsearch library.  
i made three queries in must clause and i want that:  
1: When i send Patiendid , Practiceid and "empty" Search then the data should be showed on PatientID and PracticeID.  
2: When i send Patiendid , Practiceid and "wrong" Search then nothing should be showed. No Patiendid , no Practiceid and no Search.  
3: When i send Patiendid, Practiceid and "correct" Search then the data should be showed according to them.  
That is why i keep these three quires in must but i do not know how can i achive this thing . I hope you understood my scenario. I will wait of you replay . Thank you very much.`Preformatted text`

---

<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:** [December 20, 2023, 5:02am UTC](https://discuss.elastic.co/t/how-we-can-use-search-query-in-elastic-clients-elasticsearch/347691/2 "2023-12-20T05:02:56Z")

</div>

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