filter - Elasticsearch范围过滤器倒排索引

标签 filter elasticsearch timestamp range inverted-index

拥有数百亿个文件。文档的一个字段是时间戳(毫秒),在建立索引时使用以下映射。

  timestamp:
    type: "date"
    format: "YYYY-MM-dd HH:mm:ss||YYYY-MM-dd HH:mm:ss.SSS"
    ignore_malformed: true
    doc_values: true

搜索时,请使用范围过滤器。由于使用了doc_value,因此范围过滤器在内部使用反向索引进行搜索。这有点慢。

The execution option controls how the range filter internally executes. 
The execution option accepts the following values:
index: Uses the field’s inverted index in order to determine whether documents fall within the specified range.


如果我以另一种方式更改映射,即使用天而不是小时/秒/毫秒。
  day:
    type: "date"
    format: "YYYY-MM-dd"
    ignore_malformed: true
    doc_values: true

搜索时,使用范围过滤器,速度更快。

有人可以帮忙解释一下为什么性能有所不同。

第一个(使用秒/毫秒),反向索引(内部认为是哈希表)具有大量键。虽然第二个(仅使用几天),但反向索引的键要少得多。
是这个原因吗?

最佳答案

您的假设是正确的。如果未索引日期的时间分量,则唯一值的数量会减少。在进行范围查询时,Elasticsearch必须“循环”较少数量的发布列表,因此可以观察到性能提高。

关于filter - Elasticsearch范围过滤器倒排索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30281039/

相关文章:

filter - Ansible - 否定过滤器

sql - LINQ 到 SQL : subfilter in where conditions

Elasticsearch 比较两个索引

sql - Oracle 转换(时间戳为日期)

oracle - 尝试使用 Hibernate 映射日期字段时缺少包含下划线的列

php - 为什么 PHP 中的日期时间到时间戳转换不起作用?

javascript - 如何在 Ext JS Grid 3.2 的列标题中添加过滤器选择器

hadoop - 在配置单元中过滤

elasticsearch - Elastic Search 7 - 如何查询字段订单电子邮件的多个选项有 1.客户电子邮件、2.发货电子邮件、3.计费电子邮件

elasticsearch - ES索引名称和Stormcrawler