# \[percolate\_query\] mapping for \`percolator type\` in script(painless)

**URL:** https://discuss.elastic.co/t/percolate-query-mapping-for-percolator-type-in-script-painless/336408
**Category:** Elasticsearch
**Tags:** painless
**Created:** [June 20, 2023, 12:38am UTC](https://discuss.elastic.co/t/percolate-query-mapping-for-percolator-type-in-script-painless/336408 "2023-06-20T00:38:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![SEUNGHYO](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@SEUNGHYO](https://discuss.elastic.co/u/SEUNGHYO)
#### Post date: [June 20, 2023, 12:38am UTC](https://discuss.elastic.co/t/percolate-query-mapping-for-percolator-type-in-script-painless/336408/1 "2023-06-20T00:38:20Z")

</div>

Hello

I'm Checking how to update "percolate query" \> "percolator type" field through `_update_by_query`.  
But,

```auto
# Create Index
PUT test_shlee_percolate_20230619
{
  "mappings": {
    "properties": {
      "pa001": {
        "type": "percolator"
      },
      "a001":{
        "type": "keyword"
      }
    }
  }
}

# PUT doc
PUT test_shlee_percolate_20230619/_doc/1
{
  "query": {
    "query_string":{
      "query":"a001:(\"value\")"
    }
  }
}

```

To create a field with "update\_by\_query" on this

```auto
POST test_shlee_percolate_20230619/_update_by_query?wait_for_completion=false
{
  "script": {
    "source": "ctx._source.query.query_string.query = \"pa001:(ctx._source.a001)\"",
    "lang": "painless"
  }
}

```

I'm thinking of it in this way.  
But,

```auto
# error msg
  "error": {
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
      "ctx._source.query.query_string.query = \"pa001:(ctx._source.a001)\"",
      " ^---- HERE"
    ],
    "script": "ctx._source.query.query_string.query = \"pa001:(ctx._source.a001)\"",
    "lang": "painless",
    "position": {
      "offset": 17,
      "start": 0,
      "end": 65
    },
    "caused_by": {
      "type": "null_pointer_exception",
      "reason": "cannot access method/field [query_string] from a null def reference"
    }
  }

```

In the right side of 'script \> source', :(colon) cannot be compiled.  
Is there any other way?  
OR  
Is it some kind of bug or undeveloped?

---

<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: [July 18, 2023, 12:38am UTC](https://discuss.elastic.co/t/percolate-query-mapping-for-percolator-type-in-script-painless/336408/2 "2023-07-18T00:38:48Z")

</div>

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