elasticsearch,Java,Spring,Debugging,elasticsearch" /> elasticsearch,Java,Spring,Debugging,elasticsearch" />

Java Debug在正常运行时获取ElasticSearch响应,而不是

Java Debug在正常运行时获取ElasticSearch响应,而不是,java,spring,debugging,elasticsearch,Java,Spring,Debugging,elasticsearch,你好,我是ElasticSearch的新手,但我遇到了这个有趣的bug。如果在调试模式下运行项目,SearchResponse将返回查询。但是,如果我正常运行它,它不会。这有什么原因吗 我使用的是ElasticSearch 1.4.2,使用的是Java API传输客户端 在调试模式下,我的调试消息如下所示: DEBUG | Client Established DEBUG | db created DEBUG | Trying to get a response... DEBUG | Respo

你好,我是ElasticSearch的新手,但我遇到了这个有趣的bug。如果在调试模式下运行项目,SearchResponse将返回查询。但是,如果我正常运行它,它不会。这有什么原因吗

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

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

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"}
    } ]
  }
}
正常运行时,我的调试消息如下所示:

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足够的时间来搜索它需要的东西

问题是:

    SearchResponse allHits1 = client.prepareSearch("costamesadb").setQuery(QueryBuilders.matchAllQuery()).execute().actionGet();

可能是您的应用程序正在创建数据,然后很快就会搜索创建的数据。对于搜索,新创建的数据不会立即可见


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

如果不查看执行了哪些查询,我将无法得出任何结论。@Vinethmohan我将其添加到问题中