Execute a script on GET requests


(ddorian43) #1

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


(Alexander Reelsen) #2

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


(ddorian43) #3

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


(Alexander Reelsen) #4

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

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"
      }
    }
  }
}


(ddorian43) #5

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


(system) #6

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