# Execute a script on GET requests

**URL:** <https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461>\
**Category:** Elasticsearch\
**Created:** [August 26, 2017, 7:26pm UTC](https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461 "2017-08-26T19:26:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [August 26, 2017, 7:26pm UTC](https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461/1 "2017-08-26T19:26:15Z")

</div>

I have fairly large documents and I'd like to execute a script on GET to return a subset of it (can't do with just specifying fields unfortunately). Is this possible ?

Thanks

---

<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:** [August 28, 2017, 7:40am UTC](https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461/2 "2017-08-28T07:40:18Z")

</div>

Hey,

no it is not, a GET request can only filter for fields, but there is no script execution. What do you need the script for exactly?

--Alex

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [August 28, 2017, 8:07am UTC](https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461/3 "2017-08-28T08:07:13Z")

</div>

Hey, thanks, I tried searching and docs-looking but didn't find anything.

I have a large 50kb doc mostly consisting of an `{object: {enabled:False}` that I want to filter/process with a script and only return a subset of it (but needs to be realtime).

I may need to rethink the architecture

Thanks

---

<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:** [August 28, 2017, 1:49pm UTC](https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461/4 "2017-08-28T13:49:41Z")

</div>

If you use `object: false`, you can still use the regular source filtering, as this happens on the JSON document.

```auto
PUT foo
{
  "mappings": {
    "bar" : {
      "properties": {
        "foo" : {
          "type": "object",
          "enabled" : false
        }
      }
    }
  }
}

PUT foo/bar/1
{
  "foo" : {
    "bar" : "baz",
    "spam" : "eggs"
  },
  "indexed": "field"
}

GET foo/bar/_search
{
  "query": {
    "term": {
      "foo.bar": {
        "value": "baz"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [August 28, 2017, 4:47pm UTC](https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461/5 "2017-08-28T16:47:06Z")

</div>

I know that. But I still cant accomplish my functionality without scripting. Maybe I can do an "ids" query ? Guess thats not realtime.

---

<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:** [September 25, 2017, 4:47pm UTC](https://discuss.elastic.co/t/execute-a-script-on-get-requests/98461/6 "2017-09-25T16:47:09Z")

</div>

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