# How to get data index?

**URL:** https://discuss.elastic.co/t/how-to-get-data-index/8658
**Category:** Elasticsearch
**Created:** [August 7, 2012, 9:16am UTC](https://discuss.elastic.co/t/how-to-get-data-index/8658 "2012-08-07T09:16:16Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Bernd\_Fehling](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@Bernd\_Fehling](https://discuss.elastic.co/u/Bernd_Fehling)
#### Post date: [August 7, 2012, 9:16am UTC](https://discuss.elastic.co/t/how-to-get-data-index/8658/1 "2012-08-07T09:16:16Z")

</div>

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/](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/](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

---

<div class="post-metadata">

### Author: ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)
#### Post date: [August 7, 2012, 9:22am UTC](https://discuss.elastic.co/t/how-to-get-data-index/8658/2 "2012-08-07T09:22:35Z")

</div>

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/](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/](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/](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

---

<div class="post-metadata">

### Author: ![Bernd\_Fehling](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@Bernd\_Fehling](https://discuss.elastic.co/u/Bernd_Fehling)
#### Post date: [August 7, 2012, 9:35am UTC](https://discuss.elastic.co/t/how-to-get-data-index/8658/3 "2012-08-07T09:35:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Rafal\_Kuc\_3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rafal_kuc_3/32/799_2.png) [@Rafal\_Kuc\_3](https://discuss.elastic.co/u/Rafal_Kuc_3)
#### Post date: [August 7, 2012, 9:48am UTC](https://discuss.elastic.co/t/how-to-get-data-index/8658/4 "2012-08-07T09:48:33Z")

</div>

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](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](http://localhost:9200/index/doc/1) -d '{  
"title": "sample title"  
}'

--  
Regards,  
Rafał Kuć  
Sematext :: [http://sematext.com/](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

---

<div class="post-metadata">

### Author: ![Bernd\_Fehling](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@Bernd\_Fehling](https://discuss.elastic.co/u/Bernd_Fehling)
#### Post date: [August 7, 2012, 10:05am UTC](https://discuss.elastic.co/t/how-to-get-data-index/8658/5 "2012-08-07T10:05:36Z")

</div>

Yes, \_bulk is my friend, thanks.

Bernd

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [July 6, 2017, 3:17am UTC](https://discuss.elastic.co/t/how-to-get-data-index/8658/6 "2017-07-06T03:17:29Z")

</div>


