嘿~ 今天天气不错嘛

查询返回结果和size不匹配的问题

Elasticsearch | 作者 code4j | 发布于2018年07月06日 | 阅读数:2567

2.2.1的java api,打印了SearchRequestBuilder对象得到dsl为:
{
"from" : 0,
"size" : 1,
"query" : {
"bool" : { }
}
}

然后再打印SearchResponse对象得到返回结果:
{
"took" : 6,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
},
"hits" : {
"total" : 10,
"max_score" : 1.0,
"hits" : [ {
"_index" : "xxx",
"_type" : "bug",
"_id" : "3",
"_score" : 1.0,
"_source" : {
"id" : 3
}
}, {
"_index" : "xxx",
"_type" : "bug",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"id" : 1
}
} ]
}
}

 
设置size为1,返回值却是2?
 
然后设置size为10,返回30个,size为14,返回42个。。。什么情况呢?有和我遇到相同情况的吗
 
 
补充下,集群的慢日志我调成了1ms为了捕捉真实的dsl,发现size也没问题,但是SearchResponse怎么会返回多出那么多的数据呢
已邀请:

code4j - coder github: https://github.com/rpgmakervx

赞同来自:

找到问题了,设置了 searchType为 query_and_fetch。。
 
但是不科学啊,这个只是影响查询过程,直接返回全部文档的,为什么还会影响数据条数呢

要回复问题请先登录注册