Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search API: Allow for script fields to extract parts of the stored _source #349

Closed
kimchy opened this issue Sep 2, 2010 · 1 comment
Closed

Comments

@kimchy
Copy link
Member

kimchy commented Sep 2, 2010

The script fields support in the search API to allow to extract source elements. The extract element (and its "tree" of data) is then streamed back to the user. Here is an example:

{
    "query" : {  "match_all" : {} },
    "script_fields" : {
        "test1" : { "script" : "_source.obj1.arr" }
    }
}

Note the _source keyword here to navigate the json like model.

Its important to understand the difference between doc['my_field'].value and _source.my_field. The first, using the doc keyword, will cause the terms for that field to be loaded to memory (cached), which will result in faster execution, but more memory consumption. Also, it only allows for simple valued fields (can't return a json object from it).

The _source on the other hand causes the source to be loaded, parsed, and then only the relevant part of the json is returned.

Since its a script, logic can also be applied here.

@kimchy
Copy link
Member Author

kimchy commented Sep 2, 2010

Search API: Allow for script fields to extract parts of the stored _source, closed by cd28afe.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant