# Java search issue

**URL:** https://discuss.elastic.co/t/java-search-issue/17915
**Category:** Elasticsearch
**Created:** [June 5, 2014, 1:49am UTC](https://discuss.elastic.co/t/java-search-issue/17915 "2014-06-05T01:49:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Sunny\_Cal](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Sunny\_Cal](https://discuss.elastic.co/u/Sunny_Cal)
#### Post date: [June 5, 2014, 1:49am UTC](https://discuss.elastic.co/t/java-search-issue/17915/1 "2014-06-05T01:49:03Z")

</div>

I am running into a strange issue.  
I have created a index "alerts" and putting "alert" objects in it.  
When I do  
curl -XGET '[http://localhost:9200/twitter/\_search?q=severity:HIGH](http://localhost:9200/twitter/_search?q=severity:HIGH)'  
I get the alert objects as output.  
I also get correct results when I go to HEAD and execute the query  
{"query":{"term":{"severity":"HIGH"}}}

The results are like:

{"\_index":"alerts","\_type":"alert","\_id":"\_zR5BTp7QLCpt0Dh2-7cxA","\_score":1.7461716,"\_source":{"alertId":3,"alertName":"text 3","createdOn":1401930512641,"severity":"HIGH"}}

But when I use java to connect and get the results I get no results

Code is:  
Node node = nodeBuilder().clusterName("elasticsearch").node();  
Client client = node.client();  
SearchRequestBuilder srb = client  
.prepareSearch("alerts")  
.setTypes("alert")  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(QueryBuilders.termQuery("severity", "HIGH")) ;  
System.out.println("Sending:" + srb.toString());  
SearchResponse response = srb.execute().actionGet();  
System.out.println("Searched");  
System.out.println("GOT ROWS:" + response.toString());

Output is:

Sending:{  
"query" : {  
"term" : {  
"severity" : "HIGH"  
}  
}  
}  
Searched  
GOT ROWS:{  
"took" : 50,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

Can anybody help.. I have tried a lot of things but it is not working.  
I am using jdk1.7.0\_40.. if that makes any difference

Thanks  
C

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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: [June 5, 2014, 5:31am UTC](https://discuss.elastic.co/t/java-search-issue/17915/2 "2014-06-05T05:31:08Z")

</div>

Try with high lowercase or use a match query which is analyzed.

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

Le 5 juin 2014 à 03:49, Sunny Cal [sunnycal99@gmail.com](mailto:sunnycal99@gmail.com) a écrit :

I am running into a strange issue.  
I have created a index "alerts" and putting "alert" objects in it.  
When I do  
curl -XGET '[http://localhost:9200/twitter/\_search?q=severity:HIGH](http://localhost:9200/twitter/_search?q=severity:HIGH)'  
I get the alert objects as output.  
I also get correct results when I go to HEAD and execute the query  
{"query":{"term":{"severity":"HIGH"}}}

The results are like:  
{"\_index":"alerts","\_type":"alert","\_id":"\_zR5BTp7QLCpt0Dh2-7cxA","\_score":1.7461716,"\_source":{"alertId":3,"alertName":"text 3","createdOn":1401930512641,"severity":"HIGH"}}

But when I use java to connect and get the results I get no results

Code is:  
Node node = nodeBuilder().clusterName("elasticsearch").node();  
Client client = node.client();  
SearchRequestBuilder srb = client  
.prepareSearch("alerts")  
.setTypes("alert")  
.setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
.setQuery(QueryBuilders.termQuery("severity", "HIGH")) ;  
System.out.println("Sending:" + srb.toString());  
SearchResponse response = srb.execute().actionGet();  
System.out.println("Searched");  
System.out.println("GOT ROWS:" + response.toString());

Output is:

Sending:{  
"query" : {  
"term" : {  
"severity" : "HIGH"  
}  
}  
}  
Searched  
GOT ROWS:{  
"took" : 50,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

Can anybody help.. I have tried a lot of things but it is not working.  
I am using jdk1.7.0\_40.. if that makes any difference

## Thanks C

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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/21B22A69-AFF3-46FC-867E-F836F4E1751D%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/21B22A69-AFF3-46FC-867E-F836F4E1751D%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Sunny\_Cal](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@Sunny\_Cal](https://discuss.elastic.co/u/Sunny_Cal)
#### Post date: [June 5, 2014, 5:58am UTC](https://discuss.elastic.co/t/java-search-issue/17915/3 "2014-06-05T05:58:28Z")

</div>

lower case helped.. could have never thought of that. 🙂

On Wednesday, June 4, 2014 10:31:22 PM UTC-7, David Pilato wrote:

> Try with high lowercase or use a match query which is analyzed.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 5 juin 2014 à 03:49, Sunny Cal \<[sunny...@gmail.com](mailto:sunny...@gmail.com) \<javascript:\>\> a  
> écrit :
> 
> I am running into a strange issue.  
> I have created a index "alerts" and putting "alert" objects in it.  
> When I do  
> curl -XGET '[http://localhost:9200/twitter/\_search?q=severity:HIGH](http://localhost:9200/twitter/_search?q=severity:HIGH)'  
> I get the alert objects as output.  
> I also get correct results when I go to HEAD and execute the query  
> {"query":{"term":{"severity":"HIGH"}}}
> 
> The results are like:
> 
> {"\_index":"alerts","\_type":"alert","\_id":"\_zR5BTp7QLCpt0Dh2-7cxA","\_score":1.7461716,"\_source":{"alertId":3,"alertName":"text 3","createdOn":1401930512641,"severity":"HIGH"}}
> 
> But when I use java to connect and get the results I get no results
> 
> Code is:  
> Node node = nodeBuilder().clusterName("elasticsearch").node();  
> Client client = node.client();  
> SearchRequestBuilder srb = client  
> .prepareSearch("alerts")  
> .setTypes("alert")  
> .setSearchType(SearchType.DFS\_QUERY\_THEN\_FETCH)  
> .setQuery(QueryBuilders.termQuery("severity", "HIGH")) ;  
> System.out.println("Sending:" + srb.toString());  
> SearchResponse response = srb.execute().actionGet();  
> System.out.println("Searched");  
> System.out.println("GOT ROWS:" + response.toString());
> 
> Output is:
> 
> Sending:{  
> "query" : {  
> "term" : {  
> "severity" : "HIGH"  
> }  
> }  
> }  
> Searched  
> GOT ROWS:{  
> "took" : 50,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 0,  
> "max\_score" : null,  
> "hits" :   
> }  
> }
> 
> Can anybody help.. I have tried a lot of things but it is not working.  
> I am using jdk1.7.0\_40.. if that makes any difference
> 
> Thanks  
> C
> 
> --  
> 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:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/7f15b62d-951e-48af-9acc-e9b4b10149e5%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/dce1cb71-bd6e-4b86-ba30-374d954c1af0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/dce1cb71-bd6e-4b86-ba30-374d954c1af0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:24am UTC](https://discuss.elastic.co/t/java-search-issue/17915/4 "2017-07-06T01:24:35Z")

</div>


