List append mvel

Hi

I can append to a list as follows:

PUT twitter/tweet/1
{
"list": [
{
"tweet_id": "1",
"a": "b"
},
{
"tweet_id": "123",
"a": "f"
}
]
}

POST twitter/tweet/1/_update
{
"script":
"if (!ctx._source.list.contains(newfileinfo)){ctx._source.list +=
newfileinfo}",
"params": {"newfileinfo": {"tweet_id": "3", "a": "g"}}
}

When I run the second step above repeatedly the json : {"tweet_id": "3",
"a": "g"} is not inserted which is correct.

However the version keeps changing
"_version": 2,
"_version": 3,
"_version": 4,
"_version": 5,
etc

It is concerning me that the mvel:

  •  "if (!ctx._source.list.contains(newfileinfo)) *{
    

is not working (?)

And the update is happening repeatedly and maybe what's happening is the
fragment is overwriting the document each time?

That would have performance implications ?

Thanks.

--
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/9e615825-38dd-479c-bc7e-af5f8905b876%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Elasticsearch will perform the write even if the document hasn't changed
unless you set ctx.op to "noop".

Beside the point: you should try using groovy scripting! Its a less funky
language and it seems to be more stable - like there aren't unexplained
scripting errors.

On Wed, Sep 24, 2014 at 11:06 AM, eunever32@gmail.com wrote:

Hi

I can append to a list as follows:

PUT twitter/tweet/1
{
"list": [
{
"tweet_id": "1",
"a": "b"
},
{
"tweet_id": "123",
"a": "f"
}
]
}

POST twitter/tweet/1/_update
{
"script":
"if (!ctx._source.list.contains(newfileinfo)){ctx._source.list +=
newfileinfo}",
"params": {"newfileinfo": {"tweet_id": "3", "a": "g"}}
}

When I run the second step above repeatedly the json : {"tweet_id": "3",
"a": "g"} is not inserted which is correct.

However the version keeps changing
"_version": 2,
"_version": 3,
"_version": 4,
"_version": 5,
etc

It is concerning me that the mvel:

  •  "if (!ctx._source.list.contains(newfileinfo)) *{
    

is not working (?)

And the update is happening repeatedly and maybe what's happening is the
fragment is overwriting the document each time?

That would have performance implications ?

Thanks.

--
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/9e615825-38dd-479c-bc7e-af5f8905b876%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/9e615825-38dd-479c-bc7e-af5f8905b876%40googlegroups.com?utm_medium=email&utm_source=footer
.
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/CAPmjWd2_xWowdc%3DLJkCy5A8hzVFfSsZxCxkom%3DckXzrEegh2HQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.