sorting - Elasticsearch排序是在索引分析(扫描)之后还是之前进行的?

标签 sorting elasticsearch lucene

我正在使用Elasticsearch 6.2,并且有一些查询可以分析大量文档。我正在对索引内的一个字段进行排序。 Elasticsearch检查10.000个文档(默认配置值),然后将它们分页返回。

我试图阅读文档,但是如果数据库在从索引对文档进行分析之前或之后进行排序,则找不到任何信息。

换句话说,排序是在索引分析期间直接应用还是文档在分析之后进行排序?如果最后一个选项正确,那么在扫描过程中哪种类型的应用Elasticsearch?

非常感谢。

最佳答案

Sorting, aggregations, and access to field values in scripts requires a different data access pattern. Instead of looking up the term and finding documents, we need to be able to look up the document and find the terms that it has in a field.



Elasticsearch引用文档中的这句话对我而言暗示着排序是在非分析级别上进行的,但我还决定仔细检查并对其进行一些测试。

在Elasticsearch中,我们可以对未分析的字段进行排序-例如关键词。这些字段使用doc值进行排序,测试后我可以说,它使用预先分析的值根据表示字符(数字,大写字母,小写字母)的代码进行排序

也可以通过一些警告和调整对文本字段进行排序(例如,需要启用 fielddata ,因为文本字段不支持 doc_values )

在这种情况下,根据分析值对文档进行排序。当然,很大程度上取决于分析管道,因为它可以对文本进行各种处理。另外,提醒一下:

Fielddata can consume a lot of heap space, especially when loading high cardinality text fields. Once fielddata has been loaded into the heap, it remains there for the lifetime of the segment. Also, loading fielddata is an expensive process which can cause users to experience latency hits. This is why fielddata is disabled by default.

关于sorting - Elasticsearch排序是在索引分析(扫描)之后还是之前进行的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53707084/

相关文章:

elasticsearch - ELK Logstash无法在ES中创建索引

html - 在 Kibana 4 的导航栏中添加一个页面

java - 用于子字符串搜索的 Lucene 分析器分词器

c# - 按自定义顺序对字符串数组进行排序

java - 冒泡排序代码中临时整数的作用是什么

elasticsearch - 无法使用公共(public) IP 而不是 localhost 启动 ElasticSearch

java - 无法使用 Apache Lucene 从文档中检索字段值

lucene - Azure 搜索中的模糊搜索和邻近搜索

python - 如何按字母在前的字符串列排序?

c++ - 如何从两个数组中生成一对 vector ,然后使用 CUDA/Thrust 按该对的第一个元素排序?