# Gets and searches operations using only Java client API

**URL:** https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602
**Category:** Elasticsearch
**Created:** [February 2, 2013, 2:54pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602 "2013-02-02T14:54:41Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![JJack\_PL](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@JJack\_PL](https://discuss.elastic.co/u/JJack_PL)
#### Post date: [February 2, 2013, 2:54pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/1 "2013-02-02T14:54:41Z")

</div>

When I use Java client by:  
Node node = nodeBuilder().node();  
Client client = node.client();  
and using this client to "get operation" like:  
GetResponse response = client.prepareGet("twitter", "tweet", "1")  
.execute()  
.actionGet();  
or "search operation" like:  
SearchResponse response = client.prepareSearch("test")  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(termQuery("multi", "test"))  
.setFrom(0).setSize(60).setExplain(true)  
.execute()  
.actionGet();  
I got those exceptions:

Exception in thread "main"  
org.elasticsearch.action.NoShardAvailableActionException:  
[twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]

Exception in thread "main"  
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
execute phase [dfs],  
total failure; shardFailures {[_na_][twitter][0]: No active  
shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:  
No active shards}{[_na_][twitter][3]: No active shards}{[_na_][twitter][4]:  
No active shards}

Can I do those gets ans searches by my Java client without running first ES  
started in windows?

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 2, 2013, 3:05pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/2 "2013-02-02T15:05:01Z")

</div>

Hey,  
Look at: [GitHub - elasticsearchfr/hands-on at answers](https://github.com/elasticsearchfr/hands-on/tree/answers)

BTW, you have first to create documents before being able to search for them.

HTH

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 2 févr. 2013 à 15:54, JJack\_PL [jjacek.pl@gmail.com](mailto:jjacek.pl@gmail.com) a écrit :

> When I use Java client by:  
> Node node = nodeBuilder().node();  
> Client client = node.client();  
> and using this client to "get operation" like:  
> GetResponse response = client.prepareGet("twitter", "tweet", "1")  
> .execute()  
> .actionGet();  
> or "search operation" like:  
> SearchResponse response = client.prepareSearch("test")  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(termQuery("multi", "test"))  
> .setFrom(0).setSize(60).setExplain(true)  
> .execute()  
> .actionGet();  
> I got those exceptions:
> 
> Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException:  
> [twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]
> 
> Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs],  
> total failure; shardFailures {[_na_][twitter][0]: No active shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:  
> No active shards}{[_na_][twitter][3]: No active shards}{[_na_][twitter][4]: No active shards}
> 
> ## Can I do those gets ans searches by my Java client without running first ES started in windows?
> 
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![JJack\_PL](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@JJack\_PL](https://discuss.elastic.co/u/JJack_PL)
#### Post date: [February 3, 2013, 5:53pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/3 "2013-02-03T17:53:04Z")

</div>

I have figured out I can do this gets and searches operations using only  
one node created in Java (I use default data node)  
but I have to wait after gateway recovery process will end AND until  
probably shards will be located in my one node.

So if I will run my Jave client like this:

Node node = nodeBuilder().node();  
Client client = node.client();

```
    GetResponse response = client.prepareGet("twitter", "tweet", "2") 
      .execute()
      .actionGet();

```

I will get this exception ...

lut 03, 2013 6:33:35 PM org.elasticsearch.node  
INFO: [Grog the God-Crusher] {0.20.2}[6756]: initializing ...  
lut 03, 2013 6:33:35 PM org.elasticsearch.plugins  
INFO: [Grog the God-Crusher] loaded , sites   
lut 03, 2013 6:33:37 PM org.elasticsearch.node  
INFO: [Grog the God-Crusher] {0.20.2}[6756]: initialized  
lut 03, 2013 6:33:37 PM org.elasticsearch.node  
INFO: [Grog the God-Crusher] {0.20.2}[6756]: starting ...  
lut 03, 2013 6:33:37 PM org.elasticsearch.transport  
INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9300]},  
publish\_address {inet[/192.168.0.101:9300]}  
lut 03, 2013 6:33:40 PM org.elasticsearch.cluster.service  
INFO: [Grog the God-Crusher] new\_master [Grog the  
God-Crusher][kBlV01OYSBuyQvRk3my19w][inet[/192.168.0.101:9300]], reason:  
zen-disco-join (elected\_as\_master)  
lut 03, 2013 6:33:40 PM org.elasticsearch.discovery  
INFO: [Grog the God-Crusher] elasticsearch/kBlV01OYSBuyQvRk3my19w  
lut 03, 2013 6:33:40 PM org.elasticsearch.http  
INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9200]},  
publish\_address {inet[/192.168.0.101:9200]}  
lut 03, 2013 6:33:40 PM org.elasticsearch.node  
INFO: [Grog the God-Crusher] {0.20.2}[6756]: started  
Exception in thread "main"  
org.elasticsearch.action.NoShardAvailableActionException: [twitter][3] No  
shard available for [[twitter][tweet][2]: routing [null]]

And for example if I will run Java client with more time to Gateway recover  
and alocate shards like this:

Node node = nodeBuilder().node();  
Client client = node.client();

```
    Thread.sleep(2000);
    
    GetResponse response = client.prepareGet("twitter", "tweet", "2") 
      .execute()
      .actionGet();

```

.  
.  
.  
INFO: [Time Bomb] {0.20.2}[6164]: started  
lut 03, 2013 6:38:41 PM org.elasticsearch.gateway  
INFO: [Time Bomb] recovered [20] indices into cluster\_state

I wont get any exception and all will work ok.

Can I use any API to find out when I restart cluster (Gateway recovery) to  
check if all alocating shards process is done?  
If so I could then execute safely operations like gets and searches without  
to be worry about any shard exeption etc.

W dniu sobota, 2 lutego 2013 16:05:01 UTC+1 użytkownik David Pilato napisał:

> Hey,  
> Look at: [GitHub - elasticsearchfr/hands-on at answers](https://github.com/elasticsearchfr/hands-on/tree/answers)
> 
> BTW, you have first to create documents before being able to search for  
> them.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 2 févr. 2013 à 15:54, JJack\_PL \<[jjac...@gmail.com](mailto:jjac...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> When I use Java client by:  
> Node node = nodeBuilder().node();  
> Client client = node.client();  
> and using this client to "get operation" like:  
> GetResponse response = client.prepareGet("twitter", "tweet", "1")  
> .execute()  
> .actionGet();  
> or "search operation" like:  
> SearchResponse response = client.prepareSearch("test")  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(termQuery("multi", "test"))  
> .setFrom(0).setSize(60).setExplain(true)  
> .execute()  
> .actionGet();  
> I got those exceptions:
> 
> Exception in thread "main"  
> org.elasticsearch.action.NoShardAvailableActionException:  
> [twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]
> 
> Exception in thread "main"  
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> execute phase [dfs],  
> total failure; shardFailures {[_na_][twitter][0]: No active  
> shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:  
> No active shards}{[_na_][twitter][3]: No active  
> shards}{[_na_][twitter][4]: No active shards}
> 
> Can I do those gets ans searches by my Java client without running first  
> ES started in windows?
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [February 3, 2013, 6:03pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/4 "2013-02-03T18:03:53Z")

</div>

Hello!

Maybe you can just wait for yellow or green status ? If you can just execute a code like:

client.admin().cluster().health(new ClusterHealthRequest().waitForGreenStatus()).actionGet();

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

I have figured out I can do this gets and searches operations using only one node created in Java (I use default data node)

but I have to wait after gateway recovery process will end AND until probably shards will be located in my one node.

So if I will run my Jave client like this:

Node node = nodeBuilder().node();

```
    Client client = node.client();

    

    GetResponse response = client.prepareGet("twitter", "tweet", "2") 

      .execute()

      .actionGet();

```

I will get this exception ...

lut 03, 2013 6:33:35 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: initializing ...

lut 03, 2013 6:33:35 PM org.elasticsearch.plugins

INFO: [Grog the God-Crusher] loaded [], sites []

lut 03, 2013 6:33:37 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: initialized

lut 03, 2013 6:33:37 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: starting ...

lut 03, 2013 6:33:37 PM org.elasticsearch.transport

INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish\_address {inet[/192.168.0.101:9300]}

lut 03, 2013 6:33:40 PM org.elasticsearch.cluster.service

INFO: [Grog the God-Crusher] new\_master [Grog the God-Crusher][kBlV01OYSBuyQvRk3my19w][inet[/192.168.0.101:9300]], reason: zen-disco-join (elected\_as\_master)

lut 03, 2013 6:33:40 PM org.elasticsearch.discovery

INFO: [Grog the God-Crusher] elasticsearch/kBlV01OYSBuyQvRk3my19w

lut 03, 2013 6:33:40 PM org.elasticsearch.http

INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish\_address {inet[/192.168.0.101:9200]}

lut 03, 2013 6:33:40 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: started

Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException: [twitter][3] No shard available for [[twitter][tweet][2]: routing [null]]

And for example if I will run Java client with more time to Gateway recover and alocate shards like this:

Node node = nodeBuilder().node();

```
    Client client = node.client();

    

    Thread.sleep(2000);

    

    GetResponse response = client.prepareGet("twitter", "tweet", "2") 

      .execute()

      .actionGet();

```

.

.

.

INFO: [Time Bomb] {0.20.2}[6164]: started

lut 03, 2013 6:38:41 PM org.elasticsearch.gateway

INFO: [Time Bomb] recovered [20] indices into cluster\_state

I wont get any exception and all will work ok.

Can I use any API to find out when I restart cluster (Gateway recovery) to check if all alocating shards process is done?

If so I could then execute safely operations like gets and searches without to be worry about any shard exeption etc.

W dniu sobota, 2 lutego 2013 16:05:01 UTC+1 użytkownik David Pilato napisał:

Hey,

Look at: [https://github.com/](https://github.com/elasticsearchfr/hands-on/tree/answers)[elasticsearchfr/hands-on/tree/](https://github.com/elasticsearchfr/hands-on/tree/answers)[answers](https://github.com/elasticsearchfr/hands-on/tree/answers)

BTW, you have first to create documents before being able to search for them.

HTH

--

David 😉

Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 2 févr. 2013 à 15:54, JJack\_PL \<jjac...@gmail.com\> a écrit :

When I use Java client by:

Node node = nodeBuilder().node();

Client client = node.client();

and using this client to "get operation" like:

GetResponse response = client.prepareGet("twitter", "tweet", "1")

```
      .execute()

      .actionGet();

```

or "search operation" like:

SearchResponse response = client.prepareSearch("test")

```
      .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)

      .setQuery(termQuery("multi", "test"))

      .setFrom(0).setSize(60).setExplain(true)

      .execute()

      .actionGet();

```

I got those exceptions:

Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException:

[twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]

Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs],

total failure; shardFailures {[_na_][twitter][0]: No active shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:

No active shards}{[_na_][twitter][3]: No active shards}{[_na_][twitter][4]: No active shards}

Can I do those gets ans searches by my Java client without running first ES started in windows?

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearc...@googlegroups.com.

For more options, visit [https://groups.google.com/](https://groups.google.com/groups/opt_out)[groups/opt\_out](https://groups.google.com/groups/opt_out).

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![JJack\_PL](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@JJack\_PL](https://discuss.elastic.co/u/JJack_PL)
#### Post date: [February 3, 2013, 6:37pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/5 "2013-02-03T18:37:54Z")

</div>

It works very well, thx!

W dniu niedziela, 3 lutego 2013 19:03:53 UTC+1 użytkownik Rafał Kuć napisał:

> Hello!
> 
> Maybe you can just wait for yellow or green status ? If you can just  
> execute a code like:
> 
> client.admin().cluster().health(new  
> ClusterHealthRequest().waitForGreenStatus()).actionGet();
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> Elasticsearch
> 
> - 
> 
> I have figured out I can do this gets and searches operations using only  
> one node created in Java (I use default data node)  
> but I have to wait after gateway recovery process will end AND until  
> probably shards will be located in my one node.
> 
> So if I will run my Jave client like this:
> 
> Node node = nodeBuilder().node();  
> Client client = node.client();
> 
> ```
> GetResponse response = client.prepareGet("twitter", "tweet", "2") 
> .execute()
> .actionGet();
> 
> ```
> 
> I will get this exception ...
> 
> lut 03, 2013 6:33:35 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: initializing ...  
> lut 03, 2013 6:33:35 PM org.elasticsearch.plugins  
> INFO: [Grog the God-Crusher] loaded , sites   
> lut 03, 2013 6:33:37 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: initialized  
> lut 03, 2013 6:33:37 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: starting ...  
> lut 03, 2013 6:33:37 PM org.elasticsearch.transport  
> INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9300]},  
> publish\_address {inet[/192.168.0.101:9300]}  
> lut 03, 2013 6:33:40 PM org.elasticsearch.cluster.service  
> INFO: [Grog the God-Crusher] new\_master [Grog the  
> God-Crusher][kBlV01OYSBuyQvRk3my19w][inet[/192.168.0.101:9300]], reason:  
> zen-disco-join (elected\_as\_master)  
> lut 03, 2013 6:33:40 PM org.elasticsearch.discovery  
> INFO: [Grog the God-Crusher] elasticsearch/kBlV01OYSBuyQvRk3my19w  
> lut 03, 2013 6:33:40 PM org.elasticsearch.http  
> INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9200]},  
> publish\_address {inet[/192.168.0.101:9200]}  
> lut 03, 2013 6:33:40 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: started  
> Exception in thread "main"  
> org.elasticsearch.action.NoShardAvailableActionException: [twitter][3] No  
> shard available for [[twitter][tweet][2]: routing [null]]
> 
> And for example if I will run Java client with more time to Gateway  
> recover and alocate shards like this:
> 
> Node node = nodeBuilder().node();  
> Client client = node.client();
> 
> ```
> Thread.sleep(2000);
>     
> GetResponse response = client.prepareGet("twitter", "tweet", "2") 
> .execute()
> .actionGet();
> 
> ```
> 
> .  
> .  
> .  
> INFO: [Time Bomb] {0.20.2}[6164]: started  
> lut 03, 2013 6:38:41 PM org.elasticsearch.gateway  
> INFO: [Time Bomb] recovered [20] indices into cluster\_state
> 
> I wont get any exception and all will work ok.
> 
> Can I use any API to find out when I restart cluster (Gateway recovery) to  
> check if all alocating shards process is done?  
> If so I could then execute safely operations like gets and searches  
> without to be worry about any shard exeption etc.
> 
> W dniu sobota, 2 lutego 2013 16:05:01 UTC+1 użytkownik David Pilato  
> napisał:  
> Hey,  
> Look at: [https://github.com/](https://github.com/)[https://github.com/elasticsearchfr/hands-on/tree/answers](https://github.com/elasticsearchfr/hands-on/tree/answers)  
> elasticsearchfr/hands-on/tree/[https://github.com/elasticsearchfr/hands-on/tree/answers](https://github.com/elasticsearchfr/hands-on/tree/answers)  
> answers [https://github.com/elasticsearchfr/hands-on/tree/answers](https://github.com/elasticsearchfr/hands-on/tree/answers)
> 
> BTW, you have first to create documents before being able to search for  
> them.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 2 févr. 2013 à 15:54, JJack\_PL [jjac...@gmail.com](mailto:jjac...@gmail.com) a écrit :
> 
> When I use Java client by:  
> Node node = nodeBuilder().node();  
> Client client = node.client();  
> and using this client to "get operation" like:  
> GetResponse response = client.prepareGet("twitter", "tweet", "1")  
> .execute()  
> .actionGet();  
> or "search operation" like:  
> SearchResponse response = client.prepareSearch("test")  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(termQuery("multi", "test"))  
> .setFrom(0).setSize(60).setExplain(true)  
> .execute()  
> .actionGet();  
> I got those exceptions:
> 
> Exception in thread "main"  
> org.elasticsearch.action.NoShardAvailableActionException:  
> [twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]
> 
> Exception in thread "main"  
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> execute phase [dfs],  
> total failure; shardFailures {[_na_][twitter][0]: No active  
> shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:  
> No active shards}{[_na_][twitter][3]: No active  
> shards}{[_na_][twitter][4]: No active shards}
> 
> ## Can I do those gets ans searches by my Java client without running first ES started in windows?
> 
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> For more options, visit [https://groups.google.com/](https://groups.google.com/)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> groups/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![JJack\_PL](https://avatars.discourse-cdn.com/v4/letter/j/e47c2d/32.png) [@JJack\_PL](https://discuss.elastic.co/u/JJack_PL)
#### Post date: [February 3, 2013, 6:57pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/6 "2013-02-03T18:57:58Z")

</div>

But this takes some time (like 30 sec)  
Could I make some less drastic requirements and still get the job done?

2013/2/3 Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl)

> Hello!
> 
> Maybe you can just wait for yellow or green status ? If you can just  
> execute a code like:
> 
> client.admin().cluster().health(new  
> ClusterHealthRequest().waitForGreenStatus()).actionGet();
> 
> \*--  
> Regards,  
> Rafał Kuć  
> Sematext :: _[http://sematext.com/](http://sematext.com/)_ :: Solr - Lucene - Nutch -  
> Elasticsearch
> 
> - 
> 
> I have figured out I can do this gets and searches operations using only  
> one node created in Java (I use default data node)  
> but I have to wait after gateway recovery process will end AND until  
> probably shards will be located in my one node.
> 
> So if I will run my Jave client like this:
> 
> Node node = nodeBuilder().node();  
> Client client = node.client();
> 
> ```
> GetResponse response = client.prepareGet("twitter", "tweet", "2")
> .execute()
> .actionGet();
> 
> ```
> 
> I will get this exception ...
> 
> lut 03, 2013 6:33:35 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: initializing ...  
> lut 03, 2013 6:33:35 PM org.elasticsearch.plugins  
> INFO: [Grog the God-Crusher] loaded , sites   
> lut 03, 2013 6:33:37 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: initialized  
> lut 03, 2013 6:33:37 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: starting ...  
> lut 03, 2013 6:33:37 PM org.elasticsearch.transport  
> INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9300]},  
> publish\_address {inet[/192.168.0.101:9300]}  
> lut 03, 2013 6:33:40 PM org.elasticsearch.cluster.service  
> INFO: [Grog the God-Crusher] new\_master [Grog the  
> God-Crusher][kBlV01OYSBuyQvRk3my19w][inet[/192.168.0.101:9300]], reason:  
> zen-disco-join (elected\_as\_master)  
> lut 03, 2013 6:33:40 PM org.elasticsearch.discovery  
> INFO: [Grog the God-Crusher] elasticsearch/kBlV01OYSBuyQvRk3my19w  
> lut 03, 2013 6:33:40 PM org.elasticsearch.http  
> INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9200]},  
> publish\_address {inet[/192.168.0.101:9200]}  
> lut 03, 2013 6:33:40 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: started  
> Exception in thread "main"  
> org.elasticsearch.action.NoShardAvailableActionException: [twitter][3] No  
> shard available for [[twitter][tweet][2]: routing [null]]
> 
> And for example if I will run Java client with more time to Gateway  
> recover and alocate shards like this:
> 
> Node node = nodeBuilder().node();  
> Client client = node.client();
> 
> ```
> Thread.sleep(2000);
> 
> GetResponse response = client.prepareGet("twitter", "tweet", "2")
> .execute()
> .actionGet();
> 
> ```
> 
> .  
> .  
> .  
> INFO: [Time Bomb] {0.20.2}[6164]: started  
> lut 03, 2013 6:38:41 PM org.elasticsearch.gateway  
> INFO: [Time Bomb] recovered [20] indices into cluster\_state
> 
> I wont get any exception and all will work ok.
> 
> Can I use any API to find out when I restart cluster (Gateway recovery) to  
> check if all alocating shards process is done?  
> If so I could then execute safely operations like gets and searches  
> without to be worry about any shard exeption etc.
> 
> W dniu sobota, 2 lutego 2013 16:05:01 UTC+1 użytkownik David Pilato  
> napisał:  
> Hey,  
> Look at: [https://github.com/](https://github.com/)[https://github.com/elasticsearchfr/hands-on/tree/answers](https://github.com/elasticsearchfr/hands-on/tree/answers)  
> elasticsearchfr/hands-on/tree/[https://github.com/elasticsearchfr/hands-on/tree/answers](https://github.com/elasticsearchfr/hands-on/tree/answers)  
> answers [https://github.com/elasticsearchfr/hands-on/tree/answers](https://github.com/elasticsearchfr/hands-on/tree/answers)
> 
> BTW, you have first to create documents before being able to search for  
> them.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 2 févr. 2013 à 15:54, JJack\_PL [jjac...@gmail.com](mailto:jjac...@gmail.com) a écrit :
> 
> When I use Java client by:  
> Node node = nodeBuilder().node();  
> Client client = node.client();  
> and using this client to "get operation" like:  
> GetResponse response = client.prepareGet("twitter", "tweet", "1")  
> .execute()  
> .actionGet();  
> or "search operation" like:  
> SearchResponse response = client.prepareSearch("test")  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(termQuery("multi", "test"))  
> .setFrom(0).setSize(60).setExplain(true)  
> .execute()  
> .actionGet();  
> I got those exceptions:
> 
> Exception in thread "main"  
> org.elasticsearch.action.NoShardAvailableActionException:  
> [twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]
> 
> Exception in thread "main"  
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
> execute phase [dfs],  
> total failure; shardFailures {[_na_][twitter][0]: No active  
> shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:  
> No active shards}{[_na_][twitter][3]: No active  
> shards}{[_na_][twitter][4]: No active shards}
> 
> ## Can I do those gets ans searches by my Java client without running first ES started in windows?
> 
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> For more options, visit [https://groups.google.com/](https://groups.google.com/)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> groups/opt\_out [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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: [February 3, 2013, 7:07pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/7 "2013-02-03T19:07:21Z")

</div>

Hello!

Look here: [http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html](http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html)

Basically you have three cluster health status cases - red says not all primary shards are allocated and thus you may experience the exception you saw with no active shards. Than the yellow mean that primary shards are allocated, but one or more replicas are not. The green one means that both primaries and replicas are allocated.

You can set your code to wait for yellow status. However it may take time for ElasticSearch to get to that state and how long depends on your deployment.

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

But this takes some time (like 30 sec)

Could I make some less drastic requirements and still get the job done?

2013/2/3 Rafał Kuć \<[r.kuc@solr.pl](mailto:r.kuc@solr.pl)\>

Hello!

Maybe you can just wait for yellow or green status ? If you can just execute a code like:

client.admin().cluster().health(new ClusterHealthRequest().waitForGreenStatus()).actionGet();

_--_

Regards,

Rafał Kuć

Sematext :: [http://sematext.com/](http://sematext.com/) _:: Solr - Lucene - Nutch - ElasticSearch_

I have figured out I can do this gets and searches operations using only one node created in Java (I use default data node)

but I have to wait after gateway recovery process will end AND until probably shards will be located in my one node.

So if I will run my Jave client like this:

Node node = nodeBuilder().node();

```
    Client client = node.client();

    

    GetResponse response = client.prepareGet("twitter", "tweet", "2") 

      .execute()

      .actionGet();

```

I will get this exception ...

lut 03, 2013 6:33:35 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: initializing ...

lut 03, 2013 6:33:35 PM org.elasticsearch.plugins

INFO: [Grog the God-Crusher] loaded [], sites []

lut 03, 2013 6:33:37 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: initialized

lut 03, 2013 6:33:37 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: starting ...

lut 03, 2013 6:33:37 PM org.elasticsearch.transport

INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish\_address {inet[/[192.168.0.101:9300](http://192.168.0.101:9300)]}

lut 03, 2013 6:33:40 PM org.elasticsearch.cluster.service

INFO: [Grog the God-Crusher] new\_master [Grog the God-Crusher][kBlV01OYSBuyQvRk3my19w][inet[/192.168.0.101:9300]], reason: zen-disco-join (elected\_as\_master)

lut 03, 2013 6:33:40 PM org.elasticsearch.discovery

INFO: [Grog the God-Crusher] elasticsearch/kBlV01OYSBuyQvRk3my19w

lut 03, 2013 6:33:40 PM org.elasticsearch.http

INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish\_address {inet[/[192.168.0.101:9200](http://192.168.0.101:9200)]}

lut 03, 2013 6:33:40 PM org.elasticsearch.node

INFO: [Grog the God-Crusher] {0.20.2}[6756]: started

Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException: [twitter][3] No shard available for [[twitter][tweet][2]: routing [null]]

And for example if I will run Java client with more time to Gateway recover and alocate shards like this:

Node node = nodeBuilder().node();

```
    Client client = node.client();

    

    Thread.sleep(2000);

    

    GetResponse response = client.prepareGet("twitter", "tweet", "2") 

      .execute()

      .actionGet();

```

.

.

.

INFO: [Time Bomb] {0.20.2}[6164]: started

lut 03, 2013 6:38:41 PM org.elasticsearch.gateway

INFO: [Time Bomb] recovered [20] indices into cluster\_state

I wont get any exception and all will work ok.

Can I use any API to find out when I restart cluster (Gateway recovery) to check if all alocating shards process is done?

If so I could then execute safely operations like gets and searches without to be worry about any shard exeption etc.

W dniu sobota, 2 lutego 2013 16:05:01 UTC+1 użytkownik David Pilato napisał:

Hey,

Look at: [https://github.com/](https://github.com/elasticsearchfr/hands-on/tree/answers)[elasticsearchfr/hands-on/tree/](https://github.com/elasticsearchfr/hands-on/tree/answers)[answers](https://github.com/elasticsearchfr/hands-on/tree/answers)

BTW, you have first to create documents before being able to search for them.

HTH

--

David 😉

Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 2 févr. 2013 à 15:54, JJack\_PL \<[jjac...@gmail.com](mailto:jjac...@gmail.com)\> a écrit :

When I use Java client by:

Node node = nodeBuilder().node();

Client client = node.client();

and using this client to "get operation" like:

GetResponse response = client.prepareGet("twitter", "tweet", "1")

```
      .execute()

      .actionGet();

```

or "search operation" like:

SearchResponse response = client.prepareSearch("test")

```
      .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)

      .setQuery(termQuery("multi", "test"))

      .setFrom(0).setSize(60).setExplain(true)

      .execute()

      .actionGet();

```

I got those exceptions:

Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException:

[twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]

Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs],

total failure; shardFailures {[_na_][twitter][0]: No active shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:

No active shards}{[_na_][twitter][3]: No active shards}{[_na_][twitter][4]: No active shards}

Can I do those gets ans searches by my Java client without running first ES started in windows?

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).

For more options, visit [https://groups.google.com/](https://groups.google.com/groups/opt_out)[groups/opt\_out](https://groups.google.com/groups/opt_out).

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch%2Bunsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--

You received this message because you are subscribed to the Google Groups "elasticsearch" group.

To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).

For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 3, 2013, 7:11pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/8 "2013-02-03T19:11:52Z")

</div>

I add to Rafal's answer that you wait for 30s because you are probably using default settings for indexes, 5 shards and 1 replica.  
With a single node cluster, your cluster can not move to green because replicas are not allocated on a second node.

Waiting for yellow status will be faster.

Le 3 févr. 2013 à 20:07, Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl) a écrit :

> Hello!
> 
> Look here: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/admin-cluster-health.html)
> 
> Basically you have three cluster health status cases - red says not all primary shards are allocated and thus you may experience the exception you saw with no active shards. Than the yellow mean that primary shards are allocated, but one or more replicas are not. The green one means that both primaries and replicas are allocated.
> 
> You can set your code to wait for yellow status. However it may take time for Elasticsearch to get to that state and how long depends on your deployment.
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> 
> But this takes some time (like 30 sec)  
> Could I make some less drastic requirements and still get the job done?
> 
> 2013/2/3 Rafał Kuć [r.kuc@solr.pl](mailto:r.kuc@solr.pl)  
> Hello!
> 
> Maybe you can just wait for yellow or green status ? If you can just execute a code like:
> 
> client.admin().cluster().health(new ClusterHealthRequest().waitForGreenStatus()).actionGet();
> 
> --  
> Regards,  
> Rafał Kuć  
> Sematext :: [http://sematext.com/](http://sematext.com/) :: Solr - Lucene - Nutch - Elasticsearch
> 
> I have figured out I can do this gets and searches operations using only one node created in Java (I use default data node)  
> but I have to wait after gateway recovery process will end AND until probably shards will be located in my one node.
> 
> So if I will run my Jave client like this:
> 
> Node node = nodeBuilder().node();  
> Client client = node.client();
> 
> ```
> GetResponse response = client.prepareGet("twitter", "tweet", "2") 
> .execute()
> .actionGet();
> 
> ```
> 
> I will get this exception ...
> 
> lut 03, 2013 6:33:35 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: initializing ...  
> lut 03, 2013 6:33:35 PM org.elasticsearch.plugins  
> INFO: [Grog the God-Crusher] loaded , sites   
> lut 03, 2013 6:33:37 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: initialized  
> lut 03, 2013 6:33:37 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: starting ...  
> lut 03, 2013 6:33:37 PM org.elasticsearch.transport  
> INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish\_address {inet[/192.168.0.101:9300]}  
> lut 03, 2013 6:33:40 PM org.elasticsearch.cluster.service  
> INFO: [Grog the God-Crusher] new\_master [Grog the God-Crusher][kBlV01OYSBuyQvRk3my19w][inet[/192.168.0.101:9300]], reason: zen-disco-join (elected\_as\_master)  
> lut 03, 2013 6:33:40 PM org.elasticsearch.discovery  
> INFO: [Grog the God-Crusher] elasticsearch/kBlV01OYSBuyQvRk3my19w  
> lut 03, 2013 6:33:40 PM org.elasticsearch.http  
> INFO: [Grog the God-Crusher] bound\_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish\_address {inet[/192.168.0.101:9200]}  
> lut 03, 2013 6:33:40 PM org.elasticsearch.node  
> INFO: [Grog the God-Crusher] {0.20.2}[6756]: started  
> Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException: [twitter][3] No shard available for [[twitter][tweet][2]: routing [null]]
> 
> And for example if I will run Java client with more time to Gateway recover and alocate shards like this:
> 
> Node node = nodeBuilder().node();  
> Client client = node.client();
> 
> ```
> Thread.sleep(2000);
>     
> GetResponse response = client.prepareGet("twitter", "tweet", "2") 
> .execute()
> .actionGet();
> 
> ```
> 
> .  
> .  
> .  
> INFO: [Time Bomb] {0.20.2}[6164]: started  
> lut 03, 2013 6:38:41 PM org.elasticsearch.gateway  
> INFO: [Time Bomb] recovered [20] indices into cluster\_state
> 
> I wont get any exception and all will work ok.
> 
> Can I use any API to find out when I restart cluster (Gateway recovery) to check if all alocating shards process is done?  
> If so I could then execute safely operations like gets and searches without to be worry about any shard exeption etc.
> 
> W dniu sobota, 2 lutego 2013 16:05:01 UTC+1 użytkownik David Pilato napisał:  
> Hey,  
> Look at: [GitHub - elasticsearchfr/hands-on at answers](https://github.com/elasticsearchfr/hands-on/tree/answers)
> 
> BTW, you have first to create documents before being able to search for them.
> 
> HTH
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 2 févr. 2013 à 15:54, JJack\_PL [jjac...@gmail.com](mailto:jjac...@gmail.com) a écrit :
> 
> When I use Java client by:  
> Node node = nodeBuilder().node();  
> Client client = node.client();  
> and using this client to "get operation" like:  
> GetResponse response = client.prepareGet("twitter", "tweet", "1")  
> .execute()  
> .actionGet();  
> or "search operation" like:  
> SearchResponse response = client.prepareSearch("test")  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(termQuery("multi", "test"))  
> .setFrom(0).setSize(60).setExplain(true)  
> .execute()  
> .actionGet();  
> I got those exceptions:
> 
> Exception in thread "main" org.elasticsearch.action.NoShardAvailableActionException:  
> [twitter][2] No shard available for [[twitter][tweet][1]: routing [null]]
> 
> Exception in thread "main" org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs],  
> total failure; shardFailures {[_na_][twitter][0]: No active shards}{[_na_][twitter][1]: No active shards}{[_na_][twitter][2]:  
> No active shards}{[_na_][twitter][3]: No active shards}{[_na_][twitter][4]: No active shards}
> 
> ## Can I do those gets ans searches by my Java client without running first ES started in windows?
> 
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![mukesh](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mukesh](https://discuss.elastic.co/u/mukesh)
#### Post date: [February 25, 2013, 10:09am UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/9 "2013-02-25T10:09:42Z")

</div>

This is my java code :send the value fron jsp page

## pojo class code:

log.error(" **valuse** \*\*" +getZname()+" ==\> "+getzCurrentLocation()+"  
"+getZresumeHeadline());//Here we get the value of all filead

AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
queryFilters.add(FilterBuilders.prefixFilter("Education",  
getZeducation()));  
queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline",  
getZresumeHeadline()));  
FilterBuilder aggFilter =  
FilterBuilders.andFilter(queryFilters);

```
        SearchResponse response = client.prepareSearch("res13_index")

```

.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)

.setQuery(QueryBuilders.prefixQuery("Name",getZname()))  
.setFilter(aggFilter)

```
                                        .setFrom(10)
                                        .setSize(60)
                                        .setExplain(true)
                                        .execute()
                                        .actionGet();

```

Error:  
org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to  
execute phase [dfs], total failure; shardFailures  
{[W17rw9RHRyeEZGi-aBVlmQ][res13\_index][3]:  
SearchParseException[[res13\_index][3]: query[Name:null\*],from[10],size[60]:  
Parse Failure [Failed to parse source  
[{"from":10,"size":60,"query":{"prefix":{"Name":null}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}]]];  
nested: QueryParsingException[[res13\_index] No value specified for prefix  
filter]; }{[W17rw9RHRyeEZGi-aBVlmQ][res13\_index][2]:  
SearchParseException[[res13\_index][2]

but when Using static value

AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
queryFilters.add(FilterBuilders.prefixFilter("Education","mca));  
queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline",  
"developer"));  
FilterBuilder aggFilter =  
FilterBuilders.andFilter(queryFilters);

```
        SearchResponse response = client.prepareSearch("res13_index")

```

.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)

.setQuery(QueryBuilders.prefixQuery("Name","mukesh"))  
.setFilter(aggFilter)

```
                                        .setFrom(10)
                                        .setSize(60)
                                        .setExplain(true)
                                        .execute()
                                        .actionGet();

```

It returns a json list......

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [February 25, 2013, 10:40am UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/10 "2013-02-25T10:40:20Z")

</div>

I answered in the issue 847 you commented:

{"from":10,"size":60,  
"query":  
{"prefix":{"Name":null}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},  
{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}  
You can not do a prefixQuery with no value (null). Check your java code: getZeducation() and getZresumeHeadline() return null values.

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 25 févr. 2013 à 11:09, MUKESH PANDEY [mukeshp073@gmail.com](mailto:mukeshp073@gmail.com) a écrit :

> This is my java code :send the value fron jsp page
> 
> ## pojo class code:
> 
> log.error(" **valuse** \*\*" +getZname()+" ==\> "+getzCurrentLocation()+" "+getZresumeHeadline());//Here we get the value of all filead
> 
> AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
> queryFilters.add(FilterBuilders.prefixFilter("Education", getZeducation()));  
> queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline", getZresumeHeadline()));  
> FilterBuilder aggFilter = FilterBuilders.andFilter(queryFilters);
> 
> ```
> SearchResponse response = client.prepareSearch("res13_index")
> .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
> .setQuery(QueryBuilders.prefixQuery("Name",getZname()))
> .setFilter(aggFilter)
>                                     
> .setFrom(10)
> .setSize(60)
> .setExplain(true)
> .execute()
> .actionGet();
> 
> ```
> 
> Error:  
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [dfs], total failure; shardFailures {[W17rw9RHRyeEZGi-aBVlmQ][res13\_index][3]: SearchParseException[[res13\_index][3]: query[Name:null\*],from[10],size[60]: Parse Failure [Failed to parse source [{"from":10,"size":60,"query":{"prefix":{"Name":null}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}]]]; nested: QueryParsingException[[res13\_index] No value specified for prefix filter]; }{[W17rw9RHRyeEZGi-aBVlmQ][res13\_index][2]: SearchParseException[[res13\_index][2]
> 
> but when Using static value
> 
> AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
> queryFilters.add(FilterBuilders.prefixFilter("Education","mca));  
> queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline", "developer"));  
> FilterBuilder aggFilter = FilterBuilders.andFilter(queryFilters);
> 
> ```
> SearchResponse response = client.prepareSearch("res13_index")
> .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
> .setQuery(QueryBuilders.prefixQuery("Name","mukesh"))
> .setFilter(aggFilter)
>                                     
> .setFrom(10)
> .setSize(60)
> .setExplain(true)
> .execute()
> .actionGet();
> 
> ```
> 
> It returns a json list......
> 
> --  
> You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![mukesh](https://avatars.discourse-cdn.com/v4/letter/m/aeb1de/32.png) [@mukesh](https://discuss.elastic.co/u/mukesh)
#### Post date: [February 26, 2013, 3:48pm UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/11 "2013-02-26T15:48:19Z")

</div>

Thanks for Reply

On Mon, Feb 25, 2013 at 4:10 PM, David Pilato [david@pilato.fr](mailto:david@pilato.fr) wrote:

> I answered in the issue 847[https://github.com/elasticsearch/elasticsearch/issues/847](https://github.com/elasticsearch/elasticsearch/issues/847) you  
> commented:
> 
> {"from":10,"size":60,"query":{"prefix":{"Name":null}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}
> 
> You can not do a prefixQuery with no value (null). Check your java code:  
> getZeducation() and getZresumeHeadline() return null values.
> 
> --  
> _David Pilato_ | _Technical Advocate_ | _[Elasticsearch.com](http://Elasticsearch.com)_  
> @dadoonet [https://twitter.com/dadoonet](https://twitter.com/dadoonet) | @elasticsearchfr[https://twitter.com/elasticsearchfr](https://twitter.com/elasticsearchfr)  
> | @scrutmydocs [https://twitter.com/scrutmydocs](https://twitter.com/scrutmydocs)
> 
> Le 25 févr. 2013 à 11:09, MUKESH PANDEY [mukeshp073@gmail.com](mailto:mukeshp073@gmail.com) a écrit :
> 
> This is my java code :send the value fron jsp page
> 
> ## pojo class code:
> 
> log.error(" **valuse** \*\*" +getZname()+" ==\> "+getzCurrentLocation()+"  
> "+getZresumeHeadline());//Here we get the value of all filead
> 
> AndFilterBuilder queryFilters = FilterBuilders.andFilter();  
> queryFilters.add(FilterBuilders.prefixFilter("Education",  
> getZeducation()));  
> queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline",  
> getZresumeHeadline()));  
> FilterBuilder aggFilter =  
> FilterBuilders.andFilter(queryFilters);
> 
> ```
> SearchResponse response = client.prepareSearch("res13_index")
> 
> ```
> 
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)
> 
> .setQuery(QueryBuilders.prefixQuery("Name",getZname()))  
> .setFilter(aggFilter)
> 
> ```
> .setFrom(10)
> .setSize(60)
> .setExplain(true)
> .execute()
> .actionGet();
> 
> ```
> 
> Error:  
> org.elasticsearch.action.search.SearchPhaseExecutionException: Failed  
> to execute phase [dfs], total failure; shardFailures  
> {[W17rw9RHRyeEZGi-aBVlmQ][res13\_index][3]:  
> SearchParseException[[res13\_index][3]: query[Name:null\*],from[10],size[60]:  
> Parse Failure [Failed to parse source  
> [{"from":10,"size":60,"query":{"prefix":{"Name":null}},"filter":{"and":{"filters":[{"and":{"filters":[{"prefix":{"Education":null}},{"prefix":{"ResumeHeadline":null}}]}}]}},"explain":true}]]];  
> nested: QueryParsingException[[res13\_index] No value specified for prefix  
> filter]; }{[W17rw9RHRyeEZGi-aBVlmQ][res13\_index][2]:  
> SearchParseException[[res13\_index][2]
> 
> but when Using static value
> 
> AndFilterBuilder queryFilters = FilterBuilders.andFilter();
> 
> queryFilters.add(FilterBuilders.prefixFilter("Education","mca));  
> queryFilters.add(FilterBuilders.prefixFilter("ResumeHeadline",  
> "developer"));  
> FilterBuilder aggFilter =  
> FilterBuilders.andFilter(queryFilters);
> 
> ```
> SearchResponse response = client.prepareSearch("res13_index")
> 
> ```
> 
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)
> 
> .setQuery(QueryBuilders.prefixQuery("Name","mukesh"))  
> .setFilter(aggFilter)
> 
> ```
> .setFrom(10)
> .setSize(60)
> .setExplain(true)
> .execute()
> .actionGet();
> 
> ```
> 
> It returns a json list......
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
[mukeshp073@gmail.com](mailto:mukeshp073@gmail.com)  
Laitkor.pvt ltd

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 2:49am UTC](https://discuss.elastic.co/t/gets-and-searches-operations-using-only-java-client-api/10602/12 "2017-07-06T02:49:26Z")

</div>


