# Elasticsearch\_dsl set query size to 0 automaticly

**URL:** <https://discuss.elastic.co/t/elasticsearch-dsl-set-query-size-to-0-automaticly/159620>\
**Category:** Elasticsearch\
**Created:** [December 5, 2018, 11:06pm UTC](https://discuss.elastic.co/t/elasticsearch-dsl-set-query-size-to-0-automaticly/159620 "2018-12-05T23:06:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aviran](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Aviran](https://discuss.elastic.co/u/Aviran)\
**Post date:** [December 5, 2018, 11:06pm UTC](https://discuss.elastic.co/t/elasticsearch-dsl-set-query-size-to-0-automaticly/159620/1 "2018-12-05T23:06:58Z")

</div>

Im getting very odd behavior from `elasticseach_dsl`

Im running the following from python

```auto
es_controller.es_dsl.index('management_users') \
        .doc_type('user') \
        .filter('term', email=email).execute()

```

When it's translated by `elasticsearch_dsl` into a query, in some cases it will add `size: 0` to the query which will return 0 results.

Here's the query I see in the debug info

```auto
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "email": "aviran@domain.com"
          }
        }
      ],
      "must": [
        {
          "regexp": {
            "first_name": ".*"
          }
        }
      ]
    }
  },
  "aggs": {
    "total_cost": {
      "sum": {
        "field": "cost"
      }
    },
    "total_liters": {
      "sum": {
        "field": "liters"
      }
    }
  },
  "size": 0
}

```

The response is:

```auto
{
  "took": 13,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 0,
    "hits": []
  },
  "aggregations": {
    "total_cost": {
      "value": 0
    },
    "total_liters": {
      "value": 0
    }
  }
}

```

What am I doing wrong?

The described behavior is not consistent, on some case the outgoing query will be:

```auto
{
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "email": "aviran@domain.com"
          }
        }
      ]
    }
  }
}

```

Which works fine.

Im using:

```auto
elasticsearch 5.5.3
elasticsearch-dsl 5.4.0

```

---

<div class="post-metadata">

**Author:** ![Aviran](https://avatars.discourse-cdn.com/v4/letter/a/dec6dc/32.png) [@Aviran](https://discuss.elastic.co/u/Aviran)\
**Post date:** [December 5, 2018, 11:31pm UTC](https://discuss.elastic.co/t/elasticsearch-dsl-set-query-size-to-0-automaticly/159620/2 "2018-12-05T23:31:43Z")

</div>

the issue was with the web server running the calls to ES.

When I increased the allowed processes amount, the issue resolved itself.

---

<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:** [January 2, 2019, 11:31pm UTC](https://discuss.elastic.co/t/elasticsearch-dsl-set-query-size-to-0-automaticly/159620/3 "2019-01-02T23:31:52Z")

</div>

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