# Can't index a document, getting an UnavailableShardsException

**URL:** <https://discuss.elastic.co/t/cant-index-a-document-getting-an-unavailableshardsexception/6500>\
**Category:** Elasticsearch\
**Created:** [January 25, 2012, 7:43pm UTC](https://discuss.elastic.co/t/cant-index-a-document-getting-an-unavailableshardsexception/6500 "2012-01-25T19:43:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ittai\_Zeidman](https://avatars.discourse-cdn.com/v4/letter/i/838e76/32.png) [@Ittai\_Zeidman](https://discuss.elastic.co/u/Ittai_Zeidman)\
**Post date:** [January 25, 2012, 7:43pm UTC](https://discuss.elastic.co/t/cant-index-a-document-getting-an-unavailableshardsexception/6500/1 "2012-01-25T19:43:18Z")

</div>

Hi,  
I'm unable to index documents via the java api.  
I've compiled a set of isolated steps with a gist containing all my files  
to demonstrate my issue as I hope someone can point me to the error of my  
ways (I've been struggling with this for hours).

1. Unzip ES
2. configure the cluster.name property (mycluster)
3. configure the index.number\_of\_shards property (1)
4. configure the index.number\_of\_replicas property (0)
5. configure the network.host property (localhost)
6. run elasticsearch/bin/elasticsearch.bat
7. create an index from the commandline- curl -XPUT  
[http://localhost:9200/test\_index/](http://localhost:9200/test_index/)
8. create a mapping from the commandline- curl -XPUT  
[http://localhost:9200/test\_index/mytype/\_mapping](http://localhost:9200/test_index/mytype/_mapping) -d"at"mytypeJSONSchema.txt
9. run the cluster health api call and see that there are no  
"unassigned\_shards"- curl -XGET  
[http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)
10. run the simpleTest JUnit test and see that it throws an  
UnavailableShardsException
11. run the curl -XPUT -d"at"mytype.json  
[http://localhost:9200/test\_index/mytype/1](http://localhost:9200/test_index/mytype/1) and see that the document does go  
in

the "at" is because the group disallows "mails"  
I've included in my gist [https://gist.github.com/1678085](https://gist.github.com/1678085) the following  
files:

1. elasticsearch.yml
2. mycluster.log
3. MyType.java
4. mytype.json
5. mytypeJSONSchema.txt
6. SimpleTest.java
7. stacktrace of test

I'd really appreciate help with this issue.

Thanks

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [January 25, 2012, 9:51pm UTC](https://discuss.elastic.co/t/cant-index-a-document-getting-an-unavailableshardsexception/6500/2 "2012-01-25T21:51:33Z")

</div>

Again,

Does your node connects to the server? Use TransportClient and specifically add the address of the server you start, I think you have problem with multicast discovery on your machine. Lets work around that.

On Wednesday, January 25, 2012 at 9:43 PM, Ittai Zeidman wrote:

> Hi,  
> I'm unable to index documents via the java api.  
> I've compiled a set of isolated steps with a gist containing all my files to demonstrate my issue as I hope someone can point me to the error of my ways (I've been struggling with this for hours).
> 
> 1. Unzip ES
> 2. configure the cluster.name ([http://cluster.name](http://cluster.name)) property (mycluster)
> 3. configure the index.number\_of\_shards property (1)
> 4. configure the index.number\_of\_replicas property (0)
> 5. configure the network.host property (localhost)
> 6. run elasticsearch/bin/elasticsearch.bat
> 7. create an index from the commandline- curl -XPUT [http://localhost:9200/test\_index/](http://localhost:9200/test_index/)
> 8. create a mapping from the commandline- curl -XPUT [http://localhost:9200/test\_index/mytype/\_mapping](http://localhost:9200/test_index/mytype/_mapping) -d"at"mytypeJSONSchema.txt
> 9. run the cluster health api call and see that there are no "unassigned\_shards"- curl -XGET [http://localhost:9200/\_cluster/health?pretty=true](http://localhost:9200/_cluster/health?pretty=true)
> 10. run the simpleTest JUnit test and see that it throws an UnavailableShardsException
> 11. run the curl -XPUT -d"at"mytype.json [http://localhost:9200/test\_index/mytype/1](http://localhost:9200/test_index/mytype/1) and see that the document does go in
> 
> the "at" is because the group disallows "mails"
> 
> I've included in my gist ([Files showing elasticsearch UnavailableShardsException problem I'm having · GitHub](https://gist.github.com/1678085)) the following files:  
> elasticsearch.yml  
> mycluster.log  
> MyType.java  
> mytype.json  
> mytypeJSONSchema.txt  
> SimpleTest.java  
> stacktrace of test
> 
> I'd really appreciate help with this issue.
> 
> Thanks

---

<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:41am UTC](https://discuss.elastic.co/t/cant-index-a-document-getting-an-unavailableshardsexception/6500/3 "2017-07-06T03:41:28Z")

</div>


