无法使用搜索kick在整个数据库上搜索,因为它限制了10000记录

发布于 2025-01-28 06:10:50 字数 204 浏览 2 评论 0原文

仅通过使用此限制搜索到10000记录,无法在整个弹性搜索数据库上进行搜索,

SearchData.search('yamaha', match: :word_middle,load: false)

但是在我的数据库中,有超过十万个记录,因此,如何在整个DB上进行搜索,而不仅仅是我不是的前一万个记录能够找到一些帮助的东西将不胜感激

Unable to search on whole elastic search DB just by using

SearchData.search('yamaha', match: :word_middle,load: false)

This limits the search to 10000 records but in my DB there are more than a hundred thousand records so, how to search on the whole DB not just the first ten thousand records I'm not able to find anything a little help will be appreciated

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

捂风挽笑 2025-02-04 06:10:50

我不确定Searckick,但是Elasticsearch始终在整个索引上搜索,不仅10000回收,而且默认情况下它仅返回10个文档。您可以通过更改size参数来更改响应大小,并最大每个请求返回10000个文档。

另外,如果您有较大的索引,则它始终显示10000 for hits.total.total.value在响应中,并且要获得实际数字计数,您可以设置track_total_hits值值true

{
  "track_total_hits": true,
  "query": {
    "match" : {
      "user.id" : "elkbee"
    }
  }
}

如果您需要从Elasticsearch获得更多的10000个文档,则可以使用search_afterscroll api。您可以参考 >文档以获取更多详细信息。

I am not sure about searckick but Elasticsearch always search on entire index and not only 10000 recored but by default it returns only 10 documents in response. You can change response size by changing size parameters and max it return 10000 documents per request.

Also, if you have large index then it always show 10000 for hits.total.value in response and for getting actual number count you can set track_total_hits value to true.

{
  "track_total_hits": true,
  "query": {
    "match" : {
      "user.id" : "elkbee"
    }
  }
}

If you need to get more then 10000 documents from the Elasticsearch then you can use search_after or scroll API. you can refer this documentation for more details.

烟雨凡馨 2025-02-04 06:10:50

深度分页

默认情况下, Elasticsearch 和OpenSearch限制了第一个 10,000 结果。这就是原因。我们不建议更改此操作,但是如果您确实需要所有结果,则可以使用:

class Product < ApplicationRecord
  searchkick deep_paging: true
end

如果您只需要准确的总数,则可以使用:

Product.search("pears", body_options: {track_total_hits: true})

Deep Paging

By default, Elasticsearch and OpenSearch limit paging to the first 10,000 results. Here’s why. We don’t recommend changing this, but if you really need all results, you can use:

class Product < ApplicationRecord
  searchkick deep_paging: true
end

If you just need an accurate total count, you can instead use:

Product.search("pears", body_options: {track_total_hits: true})
影子是时光的心 2025-02-04 06:10:50

Searhkick仅将结果限制为10,000。即使数字超过10,000,它仍将在模型中的所有记录上搜索。

如果您没有看到期望的结果,则设置还有其他问题。

您是否在模型中加入了搜索kick并重新索引?

class YourModel < ApplicationRecord
  searchkick
end

在新的控制台中:yourmodel.reindex

Searhkick only limits the results to 10,000. It will still search on all records in your model, even if the number is well over 10,000.

If you aren't seeing the results you expect, there is something else wrong with your setup.

Have you included searchkick in your model and reindexed?

class YourModel < ApplicationRecord
  searchkick
end

And in a new console: YourModel.reindex

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文