Delete by query API - data option does not delete documents


(Stephan Fortelny) #1

hi,

I have a problem with the "Delete By Query API", specifically the
problem is that curl with the data ('-d') option as specified in the
documentation (http://www.elasticsearch.org/guide/reference/api/delete-
by-query.html) does not actually delete any documents.

The example from the documentation I refered to, is this one. I didn't
try them out but I am doing the same, except with different index,
type and user. However, the first command works for me, the second
does not.

$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query?
q=user:kimchy'
$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query' -d '{
"term" : { "user" : "kimchy" }
}
'

This gist (https://gist.github.com/2788743) documentates the issue
more precisely.

Thanks,

Stephan


(Stephan Fortelny) #2

I tried the same now the examples given in the documentation (https://
gist.github.com/2819256). For this I am using the same elasticsearch
installation as well as the same configuration file
"elasticsearch.yml". Thus, I think that it must having something to do
with how I index the document in the first place. I index my documents
using the node.js elasticsearchclient (git://github.com/phillro/node-
elasticsearch-client.git). The client is basically building up the
same put request as in the curls.

On May 25, 5:30 pm, Stephan Fortelny stephanforte...@gmail.com
wrote:

hi,

I have a problem with the "Delete By Query API", specifically the
problem is that curl with the data ('-d') option as specified in the
documentation (http://www.elasticsearch.org/guide/reference/api/delete-
by-query.html) does not actually delete any documents.

The example from the documentation I refered to, is this one. I didn't
try them out but I am doing the same, except with different index,
type and user. However, the first command works for me, the second
does not.

$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query?
q=user:kimchy'
$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query'-d '{
"term" : { "user" : "kimchy" }}

'

This gist (https://gist.github.com/2788743) documentates the issue
more precisely.

Thanks,

Stephan


(Igor Motov) #3

There is significant difference between term query and text query. The term
query doesn't analyze the term. So, it's looking for the
term stephanfortelny@gmail.com, which doesn't exist in your index (unless
you are using an old version of elasticsearch). Since the user field is
analyzed, you index contains two terms "stephanfortelny" and "gmail.com".
It happens to works for the term kimchy because it's the same in the
analyzed and not analyzed forms.

If you want to delete all documents that are returned by your queries, you
should use the same query in the delete-by-query call:

curl -XDELETE 'http://localhost:9200/contacts/linkedin/_query' -d '{
text: { user: { query: "stephanfortelny@gmail.com", operator: "and" } }
}'

On Monday, May 28, 2012 9:41:18 AM UTC-4, Stephan Fortelny wrote:

I tried the same now the examples given in the documentation (https://
gist.github.com/2819256). For this I am using the same elasticsearch
installation as well as the same configuration file
"elasticsearch.yml". Thus, I think that it must having something to do
with how I index the document in the first place. I index my documents
using the node.js elasticsearchclient (git://github.com/phillro/node-
elasticsearch-client.githttp://github.com/phillro/node-elasticsearch-client.git).
The client is basically building up the
same put request as in the curls.

On May 25, 5:30 pm, Stephan Fortelny stephanforte...@gmail.com
wrote:

hi,

I have a problem with the "Delete By Query API", specifically the
problem is that curl with the data ('-d') option as specified in the
documentation (http://www.elasticsearch.org/guide/reference/api/delete-
by-query.html) does not actually delete any documents.

The example from the documentation I refered to, is this one. I didn't
try them out but I am doing the same, except with different index,
type and user. However, the first command works for me, the second
does not.

$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query?
q=user:kimchy'
$ curl -XDELETE 'http://localhost:9200/twitter/tweet/_query'-d '{
"term" : { "user" : "kimchy" }}

'

This gist (https://gist.github.com/2788743) documentates the issue
more precisely.

Thanks,

Stephan


(Stephan Fortelny) #4

yes. that works - for the js api passing the data object as well. thanks a
lot!

On Tue, May 29, 2012 at 7:26 PM, Igor Motov imotov@gmail.com wrote:

There is significant difference between term query and text query. The
term query doesn't analyze the term. So, it's looking for the term
stephanfortelny@gmail.com, which doesn't exist in your index (unless you
are using an old version of elasticsearch). Since the user field is
analyzed, you index contains two terms "stephanfortelny" and "gmail.com".
It happens to works for the term kimchy because it's the same in the
analyzed and not analyzed forms.

If you want to delete all documents that are returned by your queries, you
should use the same query in the delete-by-query call:

curl -XDELETE 'http://localhost:9200/contacts/linkedin/_query' -d '{
text: { user: { query: "stephanfortelny@gmail.com", operator: "and" } }
}'

On Monday, May 28, 2012 9:41:18 AM UTC-4, Stephan Fortelny wrote:

I tried the same now the examples given in the documentation (https://
gist.github.com/2819256). For this I am using the same elasticsearch
installation as well as the same configuration file
"elasticsearch.yml". Thus, I think that it must having something to do
with how I index the document in the first place. I index my documents
using the node.js elasticsearchclient (git://github.com/phillro/**node-
elasticsearch-client.githttp://github.com/phillro/node-elasticsearch-client.git).
The client is basically building up the
same put request as in the curls.

On May 25, 5:30 pm, Stephan Fortelny stephanforte...@gmail.com
wrote:

hi,

I have a problem with the "Delete By Query API", specifically the
problem is that curl with the data ('-d') option as specified in the
documentation (http://www.elasticsearch.org/**
guide/reference/api/delete-http://www.elasticsearch.org/guide/reference/api/delete-
by-query.html) does not actually delete any documents.

The example from the documentation I refered to, is this one. I didn't
try them out but I am doing the same, except with different index,
type and user. However, the first command works for me, the second
does not.

$ curl -XDELETE 'http://localhost:9200/**twitter/tweet/_queryhttp://localhost:9200/twitter/tweet/_query?

q=user:kimchy'
$ curl -XDELETE 'http://localhost:9200/**twitter/tweet/_query'-dhttp://localhost:9200/twitter/tweet/_query'-d'{
"term" : { "user" : "kimchy" }}

'

This gist (https://gist.github.com/**2788743https://gist.github.com/2788743)
documentates the issue
more precisely.

Thanks,

Stephan


(system) #5