How to put a check before inserting data in a index

I am using java client api to index data.

IndexResponse response = client.prepareIndex("nod",
"rel").setSource(met.xb).execute().actionGet();

where met.xb contains all the data.

What I want to do here is to put a check on the data being indexed, the
program should first check if the value that is being inserted is already
there or not, if it is there, then discard it, if not then update the value.

lets say i add, a custom id field here...like this:-
string id = curr.getId().toString(); // this comes from database

IndexResponse response = client.prepareIndex("nod", "rel",
id).setSource(met.xb).execute().actionGet();

id, wont be changing, so now I can identify the json through the id, next
time I insert the data,

But how do I put a check for update/discard??

Plz help me out here.

--

Hi,

quick ideas:

Regards,
Lukas

On Sat, Dec 1, 2012 at 8:37 AM, divyanshu das divyanshu.das@gmail.comwrote:

I am using java client api to index data.

IndexResponse response = client.prepareIndex("nod",
"rel").setSource(met.xb).execute().actionGet();

where met.xb contains all the data.

What I want to do here is to put a check on the data being indexed, the
program should first check if the value that is being inserted is already
there or not, if it is there, then discard it, if not then update the value.

lets say i add, a custom id field here...like this:-
string id = curr.getId().toString(); // this comes from database

IndexResponse response = client.prepareIndex("nod", "rel",
id).setSource(met.xb).execute().actionGet();

id, wont be changing, so now I can identify the json through the id, next
time I insert the data,

But how do I put a check for update/discard??

Plz help me out here.

--

--