Problem with Bulk Indexing


(Nir Rubinstein) #1

Hello

I'm very new to ES and I'm trying to come to terms with a problem that
I have. I've installed ES on my local machine (Windows 7) and have it
running. I'm using .NET to send basic http command to ES on port 9200.
I can index single records without any problem, but when I try to
index multiple documents at once, I encounter a problem.

I send a "PUT" request to http://localhost/bulk and transfer it a json
document as shown in the example on the ES site (on a side note, the
site states to use the "_bulk" uri while I use "bulk" because the
former doesn't yield any results). I receive a 200 response with a
json result of {"ok":true,"acknowledged":true}

Every bulk command I send hereafter get a 400 "Bad Request" status
back (even though the singular index commands work as usual). What am
I missing - is there an action I need to do after sending this bulk
doc?

Any help will be greatly appreciated


(Nir Rubinstein) #2

Ok, found my first mistake - using the "bulk" uri is a mistake because
it creates an index named "bulk". I tried "PUT"ing the json document
to http://localhost:9200/_bulk but got a 500 response in return. The
body of the document is:

{ "index" : { "_index" : "test", "type" : "type1", "_id" : "3" } }
\n{ "field1" : "value2" }

notice the "\n" used to separate the metadata from the data (as shown
on the site). This is a bulk index of only 1 record, but I still can't
get it to work.
Again, any help will be welcomed!

Thanks!

On Apr 26, 3:34 pm, Nir Rubinstein nir...@gmail.com wrote:

Hello

I'm very new to ES and I'm trying to come to terms with a problem that
I have. I've installed ES on my local machine (Windows 7) and have it
running. I'm using .NET to send basic http command to ES on port 9200.
I can index single records without any problem, but when I try to
index multiple documents at once, I encounter a problem.

I send a "PUT" request tohttp://localhost/bulkand transfer it a json
document as shown in the example on the ES site (on a side note, the
site states to use the "_bulk" uri while I use "bulk" because the
former doesn't yield any results). I receive a 200 response with a
json result of {"ok":true,"acknowledged":true}

Every bulk command I send hereafter get a 400 "Bad Request" status
back (even though the singular index commands work as usual). What am
I missing - is there an action I need to do after sending this bulk
doc?

Any help will be greatly appreciated


(Clinton Gormley) #3

Hi Nir

I send a "PUT" request to http://localhost/bulk and transfer it a json
document as shown in the example on the ES site (on a side note, the
site states to use the "_bulk" uri while I use "bulk" because the
former doesn't yield any results).

You can't change the URI from '_bulk' to 'bulk' - it changes the meaning
completely: ie use index 'bulk' instead of action '_bulk'

So the question is why your original request (which does use '_bulk')
doesn't work.

You haven't provided any example of what you are actually doing (see
http://www.elasticsearch.org/help ) but perhaps you're missing the final
newline at the end of your request.

clint


(Nir Rubinstein) #4

Yup - saw my mistake - see my post above. I also tried adding a "\n"
at the end of the json document to the same effect.

Thanks again

On Apr 26, 3:45 pm, Clinton Gormley clin...@iannounce.co.uk wrote:

Hi Nir

I send a "PUT" request tohttp://localhost/bulkand transfer it a json
document as shown in the example on the ES site (on a side note, the
site states to use the "_bulk" uri while I use "bulk" because the
former doesn't yield any results).

You can't change the URI from '_bulk' to 'bulk' - it changes the meaning
completely: ie use index 'bulk' instead of action '_bulk'

So the question is why your original request (which does use '_bulk')
doesn't work.

You haven't provided any example of what you are actually doing (seehttp://www.elasticsearch.org/help) but perhaps you're missing the final
newline at the end of your request.

clint


(system) #5