How to write better scripts with MVEL

Hi,

I am trying to write script which updates a document ( deleting some fields
).
The script is ctx._source.remove("title") this allows us to delete on
field named title.
How do I change the script to delete multiple fields.
Where Can I read more about the script. I have one of the resource as
http://www.elasticsearch.org/guide/reference/api/update/

Thanks in advance.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Does something like the following work?

ctx._source.remove("title");ctx._source.remove("summary");

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 mai 2013 à 12:51, Arjit Gupta arjit292@gmail.com a écrit :

ctx._source.remove("title"

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

ctx._source.remove("title");ctx._source.remove("summary");
Works well. But I was looking for something like
ctx._source.removeAll({"title","summary"});
The number of fields can be any number, I know can concat the script that
many times and it will work.

Thanks ,
Arjit

On Sun, May 5, 2013 at 4:32 PM, David Pilato david@pilato.fr wrote:

Does something like the following work?

ctx._source.remove("title");ctx._source.remove("summary");

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 mai 2013 à 12:51, Arjit Gupta arjit292@gmail.com a écrit :

ctx._source.remove("title"

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/QDVIPOpqRhw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Using a loop might help.

{
"script": "foreach(var1 : tag1) { ctx._source.remove(var1); }",
"params": {
"tag1": [
"title",
"summary",
"nextfield"
]
}
}

U can keep updating the params as per the requirement.

-- Sujoy.

On Sunday, May 5, 2013 7:21:55 PM UTC+5:30, Arjit Gupta wrote:

ctx._source.remove("title");ctx._source.remove("summary");
Works well. But I was looking for something like
ctx._source.removeAll({"title","summary"});
The number of fields can be any number, I know can concat the script that
many times and it will work.

Thanks ,
Arjit

On Sun, May 5, 2013 at 4:32 PM, David Pilato <da...@pilato.fr<javascript:>

wrote:

Does something like the following work?

ctx._source.remove("title");ctx._source.remove("summary");

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 mai 2013 à 12:51, Arjit Gupta <arji...@gmail.com <javascript:>> a
écrit :

ctx._source.remove("title"

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/QDVIPOpqRhw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks a lot. Thats what I wanted. Can I know the where i can learn more
on it

Thanks ,
Arjit

On Mon, May 6, 2013 at 11:24 AM, Sujoy Sett sujoysett@gmail.com wrote:

Using a loop might help.

{
"script": "foreach(var1 : tag1) { ctx._source.remove(var1); }",
"params": {
"tag1": [
"title",
"summary",
"nextfield"
]
}
}

U can keep updating the params as per the requirement.

-- Sujoy.

On Sunday, May 5, 2013 7:21:55 PM UTC+5:30, Arjit Gupta wrote:

ctx._source.remove("title");ctx._source.remove("summary");
Works well. But I was looking for something like
ctx._source.removeAll({"title"
,"summary"});
The number of fields can be any number, I know can concat the script that
many times and it will work.

Thanks ,
Arjit

On Sun, May 5, 2013 at 4:32 PM, David Pilato da...@pilato.fr wrote:

Does something like the following work?

ctx._source.remove("title");**ctx._source.remove("summary");

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 mai 2013 à 12:51, Arjit Gupta arji...@gmail.com a écrit :

ctx._source.remove("title"

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/**QDVIPOpqRhw/unsubscribe?hl=en-**UShttps://groups.google.com/d/topic/elasticsearch/QDVIPOpqRhw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/QDVIPOpqRhw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.

u can try the official guide http://mvel.codehaus.org/Language+Guide+for+2.0

-- Sujoy.

On Tuesday, May 7, 2013 1:01:23 PM UTC+5:30, Arjit Gupta wrote:

Thanks a lot. Thats what I wanted. Can I know the where i can learn more
on it

Thanks ,
Arjit

On Mon, May 6, 2013 at 11:24 AM, Sujoy Sett <sujo...@gmail.com<javascript:>

wrote:

Using a loop might help.

{
"script": "foreach(var1 : tag1) { ctx._source.remove(var1); }",
"params": {
"tag1": [
"title",
"summary",
"nextfield"
]
}
}

U can keep updating the params as per the requirement.

-- Sujoy.

On Sunday, May 5, 2013 7:21:55 PM UTC+5:30, Arjit Gupta wrote:

ctx._source.remove("title");ctx._source.remove("summary");
Works well. But I was looking for something like
ctx._source.removeAll({"title"
,"summary"});
The number of fields can be any number, I know can concat the script
that many times and it will work.

Thanks ,
Arjit

On Sun, May 5, 2013 at 4:32 PM, David Pilato da...@pilato.fr wrote:

Does something like the following work?

ctx._source.remove("title");**ctx._source.remove("summary");

HTH

David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 5 mai 2013 à 12:51, Arjit Gupta arji...@gmail.com a écrit :

ctx._source.remove("title"

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/**QDVIPOpqRhw/unsubscribe?hl=en-**UShttps://groups.google.com/d/topic/elasticsearch/QDVIPOpqRhw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/QDVIPOpqRhw/unsubscribe?hl=en-US
.
To unsubscribe from this group and all its topics, send an email to
elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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.
For more options, visit https://groups.google.com/groups/opt_out.