# Query range lte return all data

**URL:** <https://discuss.elastic.co/t/query-range-lte-return-all-data/198282>\
**Category:** Elasticsearch\
**Created:** [September 5, 2019, 3:20pm UTC](https://discuss.elastic.co/t/query-range-lte-return-all-data/198282 "2019-09-05T15:20:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Guyenot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremy_guyenot/32/48640_2.png) [@Jeremy\_Guyenot](https://discuss.elastic.co/u/Jeremy_Guyenot)\
**Post date:** [September 5, 2019, 3:20pm UTC](https://discuss.elastic.co/t/query-range-lte-return-all-data/198282/1 "2019-09-05T15:20:45Z")

</div>

Hi everybody,

I encountered a problem with a "range" request with the "lte" operator alone.  
With only "lte" in the query, this returns all the data. With "gte" or "gte" / "lte", the result is the one expected.

We declared the field as data type "float". See the query below.

Is this problem known?

**Here the mapping:**

```
{
  "mapping": {
    "document": {
      "properties": {
        "container": {
          "properties": {
            "id": {
              "type": "integer"
            }
          }
        },
        "fast_search": {
          "type": "text",
          "analyzer": "analyzer_special_characters"
        },
        "form_document_containers": {
          "properties": {
            "form_instances": {
              "properties": {
                "form_field_data": {
                  "properties": {
                    "field_data_number": {
                      "type": "double",
                      "copy_to": [
                        "fast_search"
                      ]
                    },
                    "field_data_string": {
                      "type": "text",
                      "copy_to": [
                        "fast_search"
                      ]
                    },
                    "id": {
                      "type": "integer"
                    }
                  }
                },
                "id": {
                  "type": "integer"
                }
              }
            },
            "id": {
              "type": "integer"
            }
          }
        },
        "id": {
          "type": "integer"
        }
      }
    }
  }
}

```

**Here the query:**

```
GET dev_jguyenot_apiplatform/_search
{
    "query": {
      "bool": {
        "should": [
          {
            "bool": {
              "must": [
                {
                  "match": {
                    "form_document_containers.form_instances.form_model.id": "2"
                  }
                },
                {
                  "bool": {
                    "must": [
                      {
                        "match": {
                          "form_document_containers.form_instances.form_field_data.form_field.uniq_name": "TOTALTTC"
                        }
                      },
                      {
                        "range": {
                          "form_document_containers.form_instances.form_field_data.field_data_number": {
                            "lte": "100.00"
                          }
                        }
                      }
                    ]
                  }
                }
              ]
            }
          }
        ]
      }
    }
}
```

---

<div class="post-metadata">

**Author:** ![Jeremy\_Guyenot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremy_guyenot/32/48640_2.png) [@Jeremy\_Guyenot](https://discuss.elastic.co/u/Jeremy_Guyenot)\
**Post date:** [September 5, 2019, 3:26pm UTC](https://discuss.elastic.co/t/query-range-lte-return-all-data/198282/2 "2019-09-05T15:26:30Z")

</div>

We also try to change "double" to "float" but no changes.

> [@Jeremy\_Guyenot](#):
>
> "field\_data\_number": { "type": "double", "copy\_to": ["fast\_search"] },

---

<div class="post-metadata">

**Author:** ![Jeremy\_Guyenot](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jeremy_guyenot/32/48640_2.png) [@Jeremy\_Guyenot](https://discuss.elastic.co/u/Jeremy_Guyenot)\
**Post date:** [September 19, 2019, 8:34am UTC](https://discuss.elastic.co/t/query-range-lte-return-all-data/198282/3 "2019-09-19T08:34:42Z")

</div>

Up please.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [September 19, 2019, 1:38pm UTC](https://discuss.elastic.co/t/query-range-lte-return-all-data/198282/4 "2019-09-19T13:38:24Z")

</div>

you may want to replace the `should` part of the most outer bool query with a `must`.

What was the reason for picking `should` here in the first place? Maybe I am misunderstanding your intention here.

---

<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:** [October 17, 2019, 1:52pm UTC](https://discuss.elastic.co/t/query-range-lte-return-all-data/198282/5 "2019-10-17T13:52:43Z")

</div>

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