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

The NEST client for ES 7 has TermRangeQuery class, which covers the case when the rage query is used with Text and Keyword fields.

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!

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:

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

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

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