# DSL query works with search but not update\_by\_query

**URL:** https://discuss.elastic.co/t/dsl-query-works-with-search-but-not-update-by-query/257378
**Category:** Elasticsearch
**Created:** [December 2, 2020, 3:36pm UTC](https://discuss.elastic.co/t/dsl-query-works-with-search-but-not-update-by-query/257378 "2020-12-02T15:36:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![The1WhoPrtNocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/the1whoprtnocks/32/72685_2.png) [@The1WhoPrtNocks](https://discuss.elastic.co/u/The1WhoPrtNocks)
#### Post date: [December 2, 2020, 3:36pm UTC](https://discuss.elastic.co/t/dsl-query-works-with-search-but-not-update-by-query/257378/1 "2020-12-02T15:36:59Z")

</div>

Hi,

If i run the following search query i get back the documents i expect,

```auto
def get_results():
    search = es.search(
        index = "logs-*",
        body = {
            "from": 0, "size": 10000,
            "query": {
                "bool" : {
                    "must": [{"exists": {"field": "powershell.file.script_block_text"}},
                        {"range": { "@timestamp": { "gte": "now-15m", "lte": "now" } } }]
                }
            },
            "fields": ["powershell.file.script_block_text", "freq_score"],
        }
    )
    return search

```

However if i take the search query and send it to update\_by\_query, it does not seem to find the documents it did before.

```auto
def update1():
    update = es.update_by_query(
        index= "logs-*",
        body={
            "query": {
                "bool": {
                    "must": [{"exists": {"field": "powershell.file.script_block_text"}},
                             {"range": {"@timestamp": {"gte": "now-15m", "lte": "now"}}}]
                }
            },
            "script": {
                "source": "ctx._source.powershell.file.script_block_text=params.value",
                "lang": "painless",
                "params": {
                    "value": "TEST"
                }
            }
        },
    )
    return update

```

Returns:  
{'batches': 0,  
'deleted': 0,  
'failures': ,  
'noops': 0,  
'requests\_per\_second': -1.0,  
'retries': {'bulk': 0, 'search': 0},  
'throttled\_millis': 0,  
'throttled\_until\_millis': 0,  
'timed\_out': False,  
'took': 3,  
'total': 0,  
'updated': 0,  
'version\_conflicts': 0}

I have looked through the documentation and can not find anything that explains why this is occurring.

---

<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: [December 30, 2020, 3:37pm UTC](https://discuss.elastic.co/t/dsl-query-works-with-search-but-not-update-by-query/257378/2 "2020-12-30T15:37:10Z")

</div>

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