Delete a specific pin without an id


(P.V.) #1

Hi Everyone,

I'm new to the elasticsearch and I'm with a doubt regarding geo
location feature.

In a project that I'm working on, we have a few tests that are
inserting a few locations to ElasticSearch with the following code:

final void index(final double latitude, final double longitude, final
String indexName) {
final XContentBuilder locationJson =
ElasticsearchUtil.createJsonForLocation(latitude, longitude);
client.prepareIndex(indexName,
PIN).setSource(locationJson).setOperationThreaded(false).execute().actionGet(timeout);
}

This works and we already have some tests searching inside a polygon
but now I want to remove a specific "pin" (location) but the only api
that I've available is the following:

client.prepareDelete("indexName", "pin",
id).setOperationThreaded(false).execute().actionGet(timeout);

But I'm not inserting any id for my location.

How should I delete a specific pin without an id?

Thanks and sorry about the basic question..


(Ivan Brusic) #2

You can always delete by query: client.prepareDeleteByQuery(...)

http://www.elasticsearch.org/guide/reference/java-api/delete-by-query.html

--
Ivan

On Tue, Mar 27, 2012 at 5:11 PM, P.V. pedro@elanross.com wrote:

Hi Everyone,

I'm new to the elasticsearch and I'm with a doubt regarding geo
location feature.

In a project that I'm working on, we have a few tests that are
inserting a few locations to ElasticSearch with the following code:

final void index(final double latitude, final double longitude, final
String indexName) {
final XContentBuilder locationJson =
ElasticsearchUtil.createJsonForLocation(latitude, longitude);
client.prepareIndex(indexName,
PIN).setSource(locationJson).setOperationThreaded(false).execute().actionGet(timeout);
}

This works and we already have some tests searching inside a polygon
but now I want to remove a specific "pin" (location) but the only api
that I've available is the following:

client.prepareDelete("indexName", "pin",
id).setOperationThreaded(false).execute().actionGet(timeout);

But I'm not inserting any id for my location.

How should I delete a specific pin without an id?

Thanks and sorry about the basic question..


(system) #3