Elascticsearch scripting


(deep saxena) #1

I am looking for the elegant solution where script can serve the purpose.

Some of my conditions are like this :-

changing the name of the field, Some script should run as part of the query
itself and should return the modified field name.

For example

Data indexed in elasticsearch :- _myField=_myValue

I want to change the _myField to _newField so the query should
be constructed in such a way that response returned by Elasticsearch should
have _newField = _myValue in the response object.

I trying to find the script that can run dynamically that changes this
value, but not able to get that. Can anybody help on this scenarios?????
:slight_smile:

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/fe924064-35e2-4dc4-ac98-485cf322f9b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Cédric Hourcade) #2

For that specific need you can use the script fields:
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-script-fields.html

With something like:

{
"query": {
"match_all": {}
},
"script_fields": {
"_myNewField": {
"script": "_source._myField"
}
}
}

Cédric Hourcade
ced@wal.fr

On Tue, Jun 24, 2014 at 9:14 AM, deep saxena sandy100ster@gmail.com wrote:

I am looking for the elegant solution where script can serve the purpose.

Some of my conditions are like this :-

changing the name of the field, Some script should run as part of the query
itself and should return the modified field name.

For example

Data indexed in elasticsearch :- _myField=_myValue

I want to change the _myField to _newField so the query should be
constructed in such a way that response returned by Elasticsearch should
have _newField = _myValue in the response object.

I trying to find the script that can run dynamically that changes this
value, but not able to get that. Can anybody help on this scenarios????? :slight_smile:

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/fe924064-35e2-4dc4-ac98-485cf322f9b8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAJQxjPNfW6_2Ae7YOA9_s8QsR_UMZREWFGn_%2Bpe65h6P%2Bc8ZCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #3