首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Debug获得ElasticSearch响应,而正常运行不会

Debug获得ElasticSearch响应,而正常运行不会
EN

Stack Overflow用户
提问于 2015-05-05 05:57:56
回答 1查看 122关注 0票数 0

大家好,我是ElasticSearch的新手,但我遇到了一个有趣的bug。如果我在调试模式下运行我的项目,我的SearchResponse将返回查询。然而,如果我正常运行它,它不会。有什么原因会发生这种情况吗?

我使用的是ElasticSearch 1.4.2,使用的是Java API和传输客户端。

我的调试消息如在调试模式下所示:

代码语言:javascript
复制
DEBUG | Client Established
DEBUG | db created
DEBUG | Trying to get a response...
DEBUG | Response 1: org.elasticsearch.action.index.IndexResponse@1aa93fb
DEBUG | Search Response: {
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "db",
      "_type" : "user",
      "_id" : "1",
      "_score" : 1.0,
      "_source":{"user":"matt","content":"trying out Elasticsearch"}
    }, {
      "_index" : "db",
      "_type" : "user",
      "_id" : "2",
      "_score" : 1.0,
      "_source":{"user":"jim","content":"trying out Elasticsearch"}
    } ]
  }
}

我的调试消息如正常运行时所示:

代码语言:javascript
复制
DEBUG | Client Established
DEBUG | db created
DEBUG | Trying to get a response...
DEBUG | Response 1: org.elasticsearch.action.index.IndexResponse@d05471
DEBUG | Search Response: {  "took" : 1, 
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}
DEBUG | elasticsearch response: 0 hits

正常运行它是否没有给elasticsearch足够的时间来搜索它需要的东西?

查询是:

代码语言:javascript
复制
    SearchResponse allHits1 = client.prepareSearch("costamesadb").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();
EN

回答 1

Stack Overflow用户

发布于 2015-05-06 17:56:08

这可能是因为您的应用程序正在创建数据,然后很快就会搜索所创建的数据。新创建的数据不会立即显示在搜索中。

请参阅Near Real time search

您可以使用实时的GET API,请参阅GET API

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30040694

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档