# What's the equivalent of NEST TermRangeQuery in the new ES 8.x client?

**URL:** <https://discuss.elastic.co/t/whats-the-equivalent-of-nest-termrangequery-in-the-new-es-8-x-client/346538>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [November 6, 2023, 3:28pm UTC](https://discuss.elastic.co/t/whats-the-equivalent-of-nest-termrangequery-in-the-new-es-8-x-client/346538 "2023-11-06T15:28:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yansklyarenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yansklyarenko/32/125805_2.png) [@yansklyarenko](https://discuss.elastic.co/u/yansklyarenko)\
**Post date:** [November 6, 2023, 3:28pm UTC](https://discuss.elastic.co/t/whats-the-equivalent-of-nest-termrangequery-in-the-new-es-8-x-client/346538/1 "2023-11-06T15:28:51Z")

</div>

The NEST client for ES 7 has [TermRangeQuery class](https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/term-range-query-usage.html), which covers the case when the rage query is [used with Text and Keyword fields](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html).

However, I can't find the equivalent in the new ES 8.x client. There's a class called RangeQuery, but it seems that it is only there to serve as a base class for DateRangeQuery and NumericRangeQuery.

So, if there's no direct equivalent for TermsRangeQuery in ES 8.x client, what's the right way to work with generic range queries which are used with Text/Keyword fields?

Thanks in advance!

---

<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:** [November 7, 2023, 8:21am UTC](https://discuss.elastic.co/t/whats-the-equivalent-of-nest-termrangequery-in-the-new-es-8-x-client/346538/2 "2023-11-07T08:21:47Z")

</div>

Hi @yansklyarenko,

I think this was one of the convenience functions that did not made it over to the new 8.x client yet.

The equivalent functionality should be achievable by combining both queries using a BoolQuery:

```csharp
client.Search<Person>(x => x
	.Query(q => q
		.Bool(b => b
			.Must(
				m => m.Terms(/* ... */),
				m => m.Range(/* ... */))
		)
	)
);

```

---

<div class="post-metadata">

**Author:** ![yansklyarenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yansklyarenko/32/125805_2.png) [@yansklyarenko](https://discuss.elastic.co/u/yansklyarenko)\
**Post date:** [November 7, 2023, 8:50am UTC](https://discuss.elastic.co/t/whats-the-equivalent-of-nest-termrangequery-in-the-new-es-8-x-client/346538/3 "2023-11-07T08:50:48Z")

</div>

Thanks for the quick answer, @flobernd! I'll give it a try

---

<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 5, 2023, 8:51am UTC](https://discuss.elastic.co/t/whats-the-equivalent-of-nest-termrangequery-in-the-new-es-8-x-client/346538/4 "2023-12-05T08:51:25Z")

</div>

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