How to get data index?

After two days of trying back and forth to get any data index from a file I
need some help.

my mapping is:
{"base":{}}

my settings are:
{"base":{"settings":{"index.number_of_shards":"2","index.number_of_replicas":"1","index.version.created":"190899"}}}

what I'm trying to do is just loading a single doc from a file.
curl -XPOST 'http://localhost:9200/base/basedoc/' -d @mytest.json

the content of mytest.json is:
'{
"myid" : "1234567890",
"myname" : "this is my name",
"mycity" : "this is my city",
"mylocation" : "this is my location"
}'

I only get responses from curl like:
"Warning: Couldn't read data from file "mytest.json", this makes an empty
POST."
{"error":"RemoteTransportException[[node_2][inet[/129.70.12.37:9301]][index]];

nested: ElasticSearchParseException[Failed to derive xcontent from
(offset=102, length=0): [0, 0, 0, 110...
...0, 0]]; ","status":400}

If send it from command line if works:
curl -XPOST 'http://localhost:9200/base/basedoc/' -d '{

"myid" : "1234567890",
"myname" : "this is my name",
"mycity" : "this is my city",
"mylocation" : "this is my location"
}'
{"ok":true,"_index":"base","_type":"basedoc","_id":"OLMhBe_gT-y_6NykAIRikg","_version":1}

Any idea?

Bernd

Hello!

You have ' characters in the mytest.json file ? If so, try to remove them and try the command you are sending once again.

--

Regards,

Rafał Kuć

Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch

After two days of trying back and forth to get any data index from a file I need some help.

my mapping is:

{"base":{}}

my settings are:

{"base":{"settings":{"index.number_of_shards":"2","index.number_of_replicas":"1","index.version.created":"190899"}}}

what I'm trying to do is just loading a single doc from a file.

curl -XPOST 'http://localhost:9200/base/basedoc/' -d @mytest.json

the content of mytest.json is:

'{

"myid" : "1234567890",

"myname" : "this is my name",

"mycity" : "this is my city",

"mylocation" : "this is my location"

}'

I only get responses from curl like:

"Warning: Couldn't read data from file "mytest.json", this makes an empty POST."

{"error":"RemoteTransportException[[node_2][inet[/129.70.12.37:9301]][index]];

nested: ElasticSearchParseException[Failed to derive xcontent from (offset=102, length=0): [0, 0, 0, 110...

...0, 0]]; ","status":400}

If send it from command line if works:

curl -XPOST 'http://localhost:9200/base/basedoc/' -d '{

> "myid" : "1234567890",

> "myname" : "this is my name",

> "mycity" : "this is my city",

> "mylocation" : "this is my location"

> }'

{"ok":true,"_index":"base","_type":"basedoc","_id":"OLMhBe_gT-y_6NykAIRikg","_version":1}

Any idea?

Bernd

Ahhhh, yes, that was it.

So how would a multi-document file look like?
{
"myid" : "doc1"
}
{
"myid": "doc2"
}

And can I send my own _id with the document?

Bernd

Hello!

Bulk API allows you to send multiple add/delete operations with a
single API call - take a look
http://www.elasticsearch.org/guide/reference/api/bulk.html

As for setting the id, the following command indexes document to test
index, to doc type with id 1:

curl -XPUT http://localhost:9200/index/doc/1 -d '{
"title": "sample title"
}'

--
Regards,
Rafał Kuć
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch

Ahhhh, yes, that was it.

So how would a multi-document file look like?
{
"myid" : "doc1"
}
{
"myid": "doc2"
}

And can I send my own _id with the document?

Bernd

Yes, _bulk is my friend, thanks.

Bernd