弹性搜索大小无限 [英] Elastic Search size to unlimited

查看:104
本文介绍了弹性搜索大小无限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的弹性搜索。我面临一个问题,写一个搜索查询返回我的集合中所有匹配的记录。以下是我对搜索记录的查询

  {
size:total no of record//这里我需要获取总收藏记录
query:{
match:{
first_name:vineeth
}
}
}

通过运行此查询,我只得到最多10条记录,我确定有超过我的收藏中有10个匹配的记录。我搜索了很多,最后在查询中得到了size参数。但在我的情况下,我不知道记录的总计数。我认为给一个无限数量的大小变量不是一个好的做法,所以如何管理这种情况请帮我解决这个问题,谢谢

解决方案

显示所有结果并不常见,而是使用和 size 中的指定范围的结果获取。因此,您的查询(用于获取前10个结果)应如下所示:

  {
from: 0,
size:10,
query:{
match:{
first_name:vineeth
}
}
}

这应该比设置 size 到一个非常大的价值。要检查与您的查询匹配的文档数量,您可以从响应中获取 hits.total (总点击数)。


Am new to elastic search. Am facing a problem to write a search query returning all matched records in my collection. Following is my query to search record

{
   "size":"total no of record" // Here i need to get total no of records in collection
   "query": {
      "match": {
         "first_name": "vineeth"
      }
   }
}

By running this query i am only getting maximum 10 records, am sure there is more than 10 matching records in my collection. I searched a lot and finally got size parameter in query. But in my case i dont know the total count of records. I think giving an unlimited number to size variable is not a good practice, so how to manage this situation please help me to solve this issue, Thanks

解决方案

It's not very common to display all results, but rather use fromand size to specify a range of results to fetch. So your query (for fetching the first 10 results) should look something like this:

{
    "from": 0,
    "size": 10,
    "query": {
        "match": {
            "first_name": "vineeth"
        }
    }
}

This should work better than setting size to a ridiculously large value. To check how many documents matched your query you can get the hits.total (total number of hits) from the response.

这篇关于弹性搜索大小无限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆