# IndexMissingException with java client

**URL:** <https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325>\
**Category:** Elasticsearch\
**Created:** [April 13, 2012, 2:56pm UTC](https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325 "2012-04-13T14:56:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![my3sons](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@my3sons](https://discuss.elastic.co/u/my3sons)\
**Post date:** [April 13, 2012, 2:56pm UTC](https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325/1 "2012-04-13T14:56:52Z")

</div>

Hello,

I have created an index called catalog using http/curl (see below).  
However, when I then try to access that index using java client (see code  
below) it can't find it. What am I missing?

public static void main(String[] args) {  
Node node = NodeBuilder.nodeBuilder().node();  
Client client = node.client();

```
    SearchResponse response = client.prepareSearch("catalog")
            .setSearchType(SearchType.QUERY_AND_FETCH)
            .setQuery(termQuery("name", "samsung"))
            .setFrom(0).setSize(10).setExplain(true)
            .setScroll(new TimeValue(600000))
            .execute()
            .actionGet();

    System.out.println(response.toString());
```

---

<div class="post-metadata">

**Author:** ![my3sons](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@my3sons](https://discuss.elastic.co/u/my3sons)\
**Post date:** [April 13, 2012, 6:41pm UTC](https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325/2 "2012-04-13T18:41:24Z")

</div>

Sorry, I just realized I did not include my index config/mappings. I have posted them below. The index is fully populated and I get back results using REST, but still can't connect using java client.

curl -XPOST localhost:9200/catalog -d '  
{"index":  
{ "number\_of\_shards": 2,  
"number\_of\_replicas" : 1  
}  
}  
}'

curl -XPUT localhost:9200/catalog/prods/\_mapping -d '{

"terms" : {  
"properties" : {  
"name" : {  
"type" : "multi\_field",  
"fields" : {  
"name" : {"type" : "string", "index" : "analyzed", "includeInAll" : true},  
"sortName" : {"type" : "string", "index" : "not\_analyzed", "includeInAll" : false}  
}  
},  
"shortDescription" : {  
"type" : "string",  
"index" : "analyzed",  
"includeInAll" : true  
},  
"salePrice" : {  
"type" : "double",  
"index" : "analyzed",  
"includeInAll" : false  
},  
"sku" : {  
"type" : "integer",  
"index" : "no",  
"includeInAll" : false  
},  
"modelNumber" : {  
"type" : "string",  
"index" : "no",  
"includeInAll" : true  
},  
"manufacturer" : {  
"type" : "multi\_field",  
"fields" : {  
"manufacturer" : {"type" : "string", "index" : "analyzed", "includeInAll" : true},  
"rawBrand" : {"type" : "string", "index" : "not\_analyzed", "includeInAll" : false}  
}  
},  
"primaryCategoryName" : {  
"type" : "multi\_field",  
"fields" : {  
"primaryCategoryName" : {"type" : "string", "index" : "analyzed", "includeInAll" : false},  
"rawPrimaryCategoryName" : {"type" : "string", "index" : "not\_analyzed", "includeInAll" : false}  
}  
},  
"store" : {  
"type" : "string",  
"index" : "analyzed",  
"includeInAll" : false  
},  
"features": {  
"type": "object",  
"properties": {  
"feature" : {"type" : "string", "includeInAll" : false}  
}  
},  
"categoryPath": {  
"type": "object",  
"properties": {  
"name" : {"type" : "string", "includeInAll" : false},  
"id" : {"type" : "string", "includeInAll" : false}  
}  
}

```
}
  }
}

```

}'

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 13, 2012, 8:08pm UTC](https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325/3 "2012-04-13T20:08:59Z")

</div>

Your code is creating another full elasticsearch node instead of a client  
node. It should be

Node node = NodeBuilder.nodeBuilder()_.client(true)_.node();

See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/java-api/client.html) for  
an example.

On Friday, April 13, 2012 2:41:24 PM UTC-4, my3sons wrote:

> Sorry, I just realized I did not include my index config/mappings. I have  
> posted them below. The index is fully populated and I get back results  
> using  
> REST, but still can't connect using java client.
> 
> curl -XPOST localhost:9200/catalog -d '  
> {"index":  
> { "number\_of\_shards": 2,  
> "number\_of\_replicas" : 1  
> }  
> }  
> }'
> 
> curl -XPUT localhost:9200/catalog/prods/\_mapping -d '{
> 
> "terms" : {  
> "properties" : {  
> "name" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "name" : {"type" : "string", "index" : "analyzed",  
> "includeInAll" : true},  
> "sortName" : {"type" : "string", "index" :  
> "not\_analyzed",  
> "includeInAll" : false}  
> }  
> },  
> "shortDescription" : {  
> "type" : "string",  
> "index" : "analyzed",  
> "includeInAll" : true  
> },  
> "salePrice" : {  
> "type" : "double",  
> "index" : "analyzed",  
> "includeInAll" : false  
> },  
> "sku" : {  
> "type" : "integer",  
> "index" : "no",  
> "includeInAll" : false  
> },  
> "modelNumber" : {  
> "type" : "string",  
> "index" : "no",  
> "includeInAll" : true  
> },  
> "manufacturer" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "manufacturer" : {"type" : "string", "index" :  
> "analyzed",  
> "includeInAll" : true},  
> "rawBrand" : {"type" : "string", "index" :  
> "not\_analyzed",  
> "includeInAll" : false}  
> }  
> },  
> "primaryCategoryName" : {  
> "type" : "multi\_field",  
> "fields" : {  
> "primaryCategoryName" : {"type" : "string", "index" :  
> "analyzed", "includeInAll" : false},  
> "rawPrimaryCategoryName" : {"type" : "string", "index" :  
> "not\_analyzed", "includeInAll" : false}  
> }  
> },  
> "store" : {  
> "type" : "string",  
> "index" : "analyzed",  
> "includeInAll" : false  
> },  
> "features": {  
> "type": "object",  
> "properties": {  
> "feature" : {"type" : "string", "includeInAll" : false}  
> }  
> },  
> "categoryPath": {  
> "type": "object",  
> "properties": {  
> "name" : {"type" : "string", "includeInAll" : false},  
> "id" : {"type" : "string", "includeInAll" : false}  
> }  
> }
> 
> ```
> }
> }
> }
> 
> ```
> 
> }'
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-with-java-client-tp3908215p3908722.html](http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-with-java-client-tp3908215p3908722.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![my3sons](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@my3sons](https://discuss.elastic.co/u/my3sons)\
**Post date:** [April 13, 2012, 9:13pm UTC](https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325/4 "2012-04-13T21:13:01Z")

</div>

Thanks Igor!

I did try what you suggested, but still got the same error. However, I did then implement a TransportClient using the below and I got back the results I was expecting. I guess I need to dig into the details of the different clients more to better understand their behavior 🙂

```
  Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));
```

---

<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:** [April 17, 2012, 8:02am UTC](https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325/5 "2012-04-17T08:02:11Z")

</div>

The reason why you get IndexMissing is that for some reason, the node  
client can't form a cluster with the other node you started (default to use  
multicast discovery), so it forms its "own" cluster.

On Sat, Apr 14, 2012 at 12:13 AM, my3sons [carey.boldenow@gmail.com](mailto:carey.boldenow@gmail.com) wrote:

> Thanks Igor!
> 
> I did try what you suggested, but still got the same error. However, I did  
> then implement a TransportClient using the below and I got back the results  
> I was expecting. I guess I need to dig into the details of the different  
> clients more to better understand their behavior 🙂
> 
> ```
> Client client = new TransportClient().addTransportAddress(new
> 
> ```
> 
> InetSocketTransportAddress("localhost", 9300));
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-with-java-client-tp3908215p3909001.html](http://elasticsearch-users.115913.n3.nabble.com/IndexMissingException-with-java-client-tp3908215p3909001.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<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:32am UTC](https://discuss.elastic.co/t/indexmissingexception-with-java-client/7325/6 "2017-07-06T03:32:21Z")

</div>


