Elasticquent(ElasticSearch)Laravel限制 [英] Elasticquent(ElasticSearch) Laravel limit

查看:53
本文介绍了Elasticquent(ElasticSearch)Laravel限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试通过elasticSearch查询获取所有结果,但如果$ limit值为null,则它仅返回10个结果.

Hi I'm trying to get all results with elasticSearch query, but it returns only 10 results if $limit value is null.

$videos = Video::searchByQuery([
                'match' => [
                    $field => $request->$field
                ],
        ],null,null,null);

那么如何获得所有结果?

so how to get all results ?

推荐答案

这是因为

That's because the default size for requests is 10 and not passing a length limit to any framework is probably going to set it to the default. You can use from and size with large values though:

尽管from和size可以设置为请求参数,但是它们也可以在搜索正文中设置.从默认为0,大小默认为10.

Though from and size can be set as request parameters, they can also be set within the search body. from defaults to 0, and size defaults to 10.

但是,正如在与您的问题非常相似的问题中指出的那样,仅使用 from size 以及滚动

But, as pointed out in a question very similar to yours, there's no way to do an unlimited sized search just using from and size, and the ES documentation has some suggestions on search types if you really need to process a very large result set, it might be good to use scroll

scroll API可用于从单个搜索请求中检索大量结果(甚至所有结果),其方式与在传统数据库中使用光标的方式几乎相同.

the scroll API can be used to retrieve large numbers of results (or even all results) from a single search request, in much the same way as you would use a cursor on a traditional database.

滚动并非用于实时用户请求,而是用于处理大量数据

Scrolling is not intended for real time user requests, but rather for processing large amounts of data

但是请注意最后一句话,如果这是实时请求,则您可能需要仔细阅读第三个链接,以确定采取的最佳措施.

Take note of the last sentence though, if this is for a real time request you might want to read that third link carefully to decide what the best course of action to take is.

此外,如果您在问题中描述用例,可能会有所帮助,好像这是针对用户返回的结果一样,我无法想象他们想看到您的结果 all 立即使用,并且对分页方法很满意.

Also, if you describe your use case in your question, it might be helpful as if this is for a user-returned result, I can't imagine that they want to see all your results at once, and would be content with a paginated approach.

完成研究并了解基础知识之后,建议您查看正在使用的库的文档,以确定如何进行操作.

Once you've done that research and understand the underlying, I'd suggest you look in the documentation of the library you're using to determine how to proceed.

P.s.下次您问有关ES的问题时,还应包括您正在使用的版本,因为这将根据您的要求影响一些答案.

P.s. Next time you ask a question about ES also include the version you're using, as that will affect some answers depending on what you're asking about.

这篇关于Elasticquent(ElasticSearch)Laravel限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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