How to write better scripts with MVEL

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

How to write better scripts with MVEL

Arjit Gupta
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: How to write better scripts with MVEL

dadoonet
Does something like the following work?

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

HTH
--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs


Le 5 mai 2013 à 12:51, Arjit Gupta <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: How to write better scripts with MVEL

Arjit Gupta
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 <[hidden email]> wrote:
Does something like the following work?

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

HTH
--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs


Le 5 mai 2013 à 12:51, Arjit Gupta <[hidden email]> 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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: How to write better scripts with MVEL

sujoysett
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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-WimAcZ9OVQJ">da...@...> wrote:
Does something like the following work?

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

HTH
--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs


Le 5 mai 2013 à 12:51, Arjit Gupta <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-WimAcZ9OVQJ">arji...@...> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="-WimAcZ9OVQJ">elasticsearc...@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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: How to write better scripts with MVEL

Arjit Gupta
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 <[hidden email]> 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 <[hidden email]> wrote:
Does something like the following work?

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

HTH
--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs


Le 5 mai 2013 à 12:51, Arjit Gupta <[hidden email]> 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.

For more options, visit https://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 [hidden email].
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: How to write better scripts with MVEL

sujoysett
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 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZO3xmDnCIgYJ">sujo...@...> 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 <[hidden email]> wrote:
Does something like the following work?

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

HTH
--
David ;-)
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs


Le 5 mai 2013 à 12:51, Arjit Gupta <[hidden email]> 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.

For more options, visit https://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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="ZO3xmDnCIgYJ">elasticsearc...@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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.