没有从搜索/滚动中获取文档

时间:2015-11-11 11:21:15

标签: java elasticsearch

我有一个包含一个文档的索引:

[root@jupiter bin]# curl -XGET 'http://jupiter:9200/190_*/190/_search?pretty=true&scroll=5s&type=scan'
{
 "_scroll_id" : "cXVlcnlUaGVuRmV0Y2g7Njs3NjpmVlMxOTMxeFNMR3RhNDNYa2g2V1hBOzc3OmZWUzE5MzF4U0xHdGE0M1hraDZXWEE7Nzg6ZlZTMTkzMXhTTEd0YTQzWGtoNldYQTs3OTpmVlMxOTMxeFNMR3RhNDNYa2g2V1hBOzgwOmZWUzE5MzF4U0xHdGE0M1hraDZXWEE7ODE6ZlZTMTkzMXhTTEd0YTQzWGtoNldYQTswOw==",
 "took" : 23,
 "timed_out" : false,
 "_shards" : {
"total" : 6,
"successful" : 6,
"failed" : 0
},
  "hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [ {
  "_index" : "190_201511111201",
  "_type" : "190",
  "_id" : "AVD2Ng-ikZQz3DDVoI8y",
  "_score" : 1.0,
  "_source":{"cacheId":"null|null|null|null|null|null|BR6373|CL873|ENG|20080603|20080601|null|null|18.2|19.2|20.1|18.3|19.<null>|20.2|22.country|23.0|24.ESP|22.area|23.0|24.11|22.region|23.0|24.|22.city|23.0|24.|22.accommodationCode|23.1|24.|22.accommodationType|23.1|24.0|22.category|23.1|24.|22.priceType|23.2|24.3|22.offer|23.2|24.|22.concept|23.2|24.|22.board|23.2|24.|22.cancelPolicies|23.2|24.1|","cache":{"errorCode":null,"encoding":"ISO-8859-1","cacheTime":900000,"creationTime":1447239749530,"contentType":"application/xml","contentEncoding":"gzip","indexDocument":"{\"room_children\":[2,null],\"criterion_code\":[\"country\",\"area\",\"region\",\"city\",\"accommodationCode\",\"accommodationType\",\"category\",\"priceType\",\"offer\",\"concept\",\"board\",\"cancelPolicies\"]}","decompressedResponseSize":882},"search":{"room_children":[2,null],"criterion_code":["country","area","region","city","accommodationCode","accommodationType","category","priceType","offer","concept","board","cancelPolicies"]}}
} ]

} }

如果我从rest api滚动,我会收到这份文件。但是如果我使用java api搜索/滚动,则找不到文档。 代码是:

 SearchResponse searchResponse = client.prepareSearch("190_*").setTypes("190")
        .setSearchType(SearchType.SCAN)
        .setScroll(new TimeValue(60000))
        .setQuery(QueryBuilders.matchAllQuery())
        .setSize(100).execute().actionGet(); 

 System.out.println("searchResponse.getScrollId() = " + searchResponse.getScrollId());

while (true) 
{
 System.out.println("restore :: searchResponse.getHits().getHits().length = " + searchResponse.getHits().getHits().length);   

 if (searchResponse.getHits().getHits().length == 0) break;

 // Process documents here ... 

 // Start scrolling ...
 searchResponse = client.prepareSearchScroll(searchResponse.getScrollId()).setScroll(SCROLL_TIMEOUT).execute().actionGet();
}

输出结果为:

searchResponse.getScrollId() = c2Nhbjs2OzY6ZlZTMTkzMXhTTEd0YTQzWGtoNldYQTs1OmZWUzE5MzF4U0xHdGE0M1hraDZXWEE7MzpmVlMxOTMxeFNMR3RhNDNYa2g2V1hBOzI6ZlZTMTkzMXhTTEd0YTQzWGtoNldYQTs0OmZWUzE5MzF4U0xHdGE0M1hraDZXWEE7MTpmVlMxOTMxeFNMR3RhNDNYa2g2V1hBOzE7dG90YWxfaGl0czoxOw==
restore :: searchResponse.getHits().getHits().length = 0

我无法查看此查询的错误,也许是&#34; 190 _ *&#34;匹配名称以190开头的所有索引?

0 个答案:

没有答案