# Greater than based on value from another field

**URL:** <https://discuss.elastic.co/t/greater-than-based-on-value-from-another-field/129089>\
**Category:** Elasticsearch\
**Created:** [April 23, 2018, 11:40am UTC](https://discuss.elastic.co/t/greater-than-based-on-value-from-another-field/129089 "2018-04-23T11:40:34Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Dave\_Clissold](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dave_clissold/32/30296_2.png) [@Dave\_Clissold](https://discuss.elastic.co/u/Dave_Clissold)\
**Post date:** [April 23, 2018, 12:36pm UTC](https://discuss.elastic.co/t/greater-than-based-on-value-from-another-field/129089/3 "2018-04-23T12:36:36Z")

</div>

That is an idea, simple enough to build a simple string or array with an order and then just additionally match that at query time.

Do you think something similar to this would be efficient?

> [@Matching by array elements](https://discuss.elastic.co/t/matching-by-array-elements/39530/2):
>
> There isn't an efficient way to do this but I can think of two OK ways to do it and I'm not sure which one is best: Index the documents with the string array just like that and search using a bool query (bool filter in 1.x) with each term in the OR clause, probably wrapped in a constant\_score query. Then you use a script to recheck all the found documents for your restriction. Index the documents with an extra field that smooshes together the string array. So it'd be {"stringArray": ["A",…

Where I use the principal of the 'smooshed\_arrays' to create com1\_com2. the reality of my searches are likely to be 2 or 3 objects to work with, so can easily build these on the way in for example, A\_B and A\_B\_C / A\_C\_B (when 3 items to query)

---

_[View the full topic](https://discuss.elastic.co/t/greater-than-based-on-value-from-another-field/129089)._
