# Writing DSL Query to find documents for dyanmic fields in the index

**URL:** <https://discuss.elastic.co/t/writing-dsl-query-to-find-documents-for-dyanmic-fields-in-the-index/278985>\
**Category:** Elasticsearch\
**Created:** [July 18, 2021, 9:51am UTC](https://discuss.elastic.co/t/writing-dsl-query-to-find-documents-for-dyanmic-fields-in-the-index/278985 "2021-07-18T09:51:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Divyank\_Mahalle](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/divyank_mahalle/32/91240_2.png) [@Divyank\_Mahalle](https://discuss.elastic.co/u/Divyank_Mahalle)\
**Post date:** [July 18, 2021, 9:51am UTC](https://discuss.elastic.co/t/writing-dsl-query-to-find-documents-for-dyanmic-fields-in-the-index/278985/1 "2021-07-18T09:51:10Z")

</div>

Hi All,  
I want to write a DSL Query that will fetch results from fields.

```auto
GET condition/_search
{
    "query": {
        "range" : {
            "tag.value" : {
                "gte" : "operational.threshold",
                 "lte" : "threshold.caution",
                "boost" : 2.0
            }
        }
    }
}

```

As I write the above code, it's throwing an error of number format exception.  
Is there any way to find integer values using fields instead of integers in the code? As the field threshold.operational and threshold.caution dynamic fields means integer values will change with respect to time so I cannot use static integer values.  
Values I am comparing in code are as below-

```auto
tag.value
5.7
	
threshold.caution
5.5
	
threshold.operational
0.5
	
threshold.warning
11.2

```

![image](https://us1.discourse-cdn.com/elastic/original/3X/9/d/9df2a73ab35944232705af32fb82b928598d511b.png)

Output error pic attached.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/7/475fc0f7a0fcd0c43f80deeda4043b08fc610f6e.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 18, 2021, 4:35pm UTC](https://discuss.elastic.co/t/writing-dsl-query-to-find-documents-for-dyanmic-fields-in-the-index/278985/2 "2021-07-18T16:35:06Z")

</div>

> [@Divyank\_Mahalle](#):
>
> Is there any way to find integer values using fields instead of integers in the code? As the field threshold.operational and threshold.caution dynamic fields means integer values will change with respect to time so I cannot use static integer values.

The `gte` and `lte` parameters must contain values and can not take field names. If you want to compare fields within a document I suspect you will need to [use a scripted field](https://www.elastic.co/guide/en/elasticsearch/reference/7.13/search-fields.html#script-fields).

---

<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 15, 2021, 4:35pm UTC](https://discuss.elastic.co/t/writing-dsl-query-to-find-documents-for-dyanmic-fields-in-the-index/278985/3 "2021-08-15T16:35:22Z")

</div>

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