I have a "user" document which has an array of friends.
I need to add/delete friends from that array.
I'm currently being able to add or remove, but problem is that if a user ID
already exists gets added anyway.
I need to perform a check before actually adding it (desiderable in one
operation "if (not_exists) add it" ).
This is my user object and mappings (and scripts).
You can play with the 'ctx.op' field, so in your case, you can perform the
following update :
ctx._source.friends.contains(friend) ? ctx._source.friends += friend :
ctx.op = "none"
Nabloom
On Thursday, April 4, 2013 4:54:05 PM UTC+2, Fernando Javier Martin wrote:
Hi there.
I have a "user" document which has an array of friends.
I need to add/delete friends from that array.
I'm currently being able to add or remove, but problem is that if a user
ID already exists gets added anyway.
I need to perform a check before actually adding it (desiderable in one
operation "if (not_exists) add it" ).
Am I missing anything?
I've tried even removing the friend_qty update operation, just in case the
semicolon was causing something unwanted (is that the right way to put
multiple statements?).
Version number gets incremented on every POST but no changes at all to the
document.
El jueves, 4 de abril de 2013 11:54:05 UTC-3, Fernando Javier Martin
escribió:
Hi there.
I have a "user" document which has an array of friends.
I need to add/delete friends from that array.
I'm currently being able to add or remove, but problem is that if a user
ID already exists gets added anyway.
I need to perform a check before actually adding it (desiderable in one
operation "if (not_exists) add it" ).
Am I missing anything?
I've tried even removing the friend_qty update operation, just in case the
semicolon was causing something unwanted (is that the right way to put
multiple statements?).
Version number gets incremented on every POST but no changes at all to the
document.
El jueves, 4 de abril de 2013 11:54:05 UTC-3, Fernando Javier Martin
escribió:
Hi there.
I have a "user" document which has an array of friends.
I need to add/delete friends from that array.
I'm currently being able to add or remove, but problem is that if a user
ID already exists gets added anyway.
I need to perform a check before actually adding it (desiderable in one
operation "if (not_exists) add it" ).
BTW: Do(es) you(anyone) have a clue why the ternary operator version hadn't
worked?
I'm completely new to ES (hence to mvel)
he
El jueves, 4 de abril de 2013 11:54:05 UTC-3, Fernando Javier Martin
escribió:
Hi there.
I have a "user" document which has an array of friends.
I need to add/delete friends from that array.
I'm currently being able to add or remove, but problem is that if a user
ID already exists gets added anyway.
I need to perform a check before actually adding it (desiderable in one
operation "if (not_exists) add it" ).
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.