# Spring data can not get result list by elasticsearchTemplate

**URL:** <https://discuss.elastic.co/t/spring-data-can-not-get-result-list-by-elasticsearchtemplate/148689>\
**Category:** Elasticsearch\
**Created:** [September 15, 2018, 2:34am UTC](https://discuss.elastic.co/t/spring-data-can-not-get-result-list-by-elasticsearchtemplate/148689 "2018-09-15T02:34:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![freeunion1possible](https://avatars.discourse-cdn.com/v4/letter/f/7ab992/32.png) [@freeunion1possible](https://discuss.elastic.co/u/freeunion1possible)\
**Post date:** [September 15, 2018, 2:34am UTC](https://discuss.elastic.co/t/spring-data-can-not-get-result-list-by-elasticsearchtemplate/148689/1 "2018-09-15T02:34:26Z")

</div>

Hi Buddy,

In my project, included spring boot(2.0.4) + spring data+ elasticsearch.client(transport:5.6.10).

when i try to used elasticsearchTemplate query object list, its return size=0, and no errors or exception.

QueryBuilder query = QueryBuilders.boolQuery().must(QueryBuilders.boolQuery().mustNot(QueryBuilders.termQuery(Constants.VIN, StringUtils.EMPTY))  
 .must(QueryBuilders.matchPhraseQuery(Constants.MESSAGE\_CONTENT, Constants.RA\_MESSAGE\_SUCESS))  
 .filter(QueryBuilders.rangeQuery(Constants.LOG\_TIME).gte("2018-08-13 13:47:00").lte("2018-08-13 13:47:59")));  
name.setName(currentIndexName);  
SearchQuery searchQuery = new NativeSearchQueryBuilder().withIndices(currentIndexName).withTypes("log").withQuery(query).build();  
System.out.println(searchQuery.getQuery());  
List\<LoggerProperty\> list = elasticsearchTemplate.queryForList(searchQuery, LoggerProperty.class);

Meanwhile, i pasted the console output DSL(XXXX), and add "query": { XXXX } , it work well in postman.

Is there anybody can help me to clearify the problem, thanks in advance!

---

<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:** [October 13, 2018, 2:34am UTC](https://discuss.elastic.co/t/spring-data-can-not-get-result-list-by-elasticsearchtemplate/148689/2 "2018-10-13T02:34:31Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
