Skip to content

Unable to create filtered alias, using range, data_nanos and negative offsets(now-7d) #54315

@cpitchford

Description

@cpitchford

Elasticsearch version (bin/elasticsearch --version): OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Version: 7.6.1, Build: default/docker/aa751e09be0a5072e8570670309b1f12348f023b/2020-02-29T00:15:25.529771Z, JVM: 13.0.2

Plugins installed: []

JVM version (java -version): openjdk version "13.0.2" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 13.0.2+8)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 13.0.2+8, mixed mode, sharing)

OS version (uname -a if on a Unix-like system): Linux ad9271944652 4.19.76-linuxkit #1 SMP Thu Oct 17 19:31:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Error is returned when attempting to create a filtered alias that uses a range, with a data_nanos field, using now, and a negative offset (such as now-7d)

This error does not appear when using date fields or when using positive offsets (such as now+7d)

Steps to reproduce:

  1. Create index with date_nanos field
PUT date_source
{
  "mappings": {
    "properties": {
      "date": {
        "type": "date"
      },
      "date_nanos": {
        "type": "date_nanos"
      }
    }
  }
}
  1. Create a filtered alias, filtering data_nanos field using negative offset (now-7d/d)
PUT date_source/_alias/date_nanos_alias
{
  "filter": {
   "range": {
      "date_nanos": {
        "gt": "now-7d/d"
      }
    }
  }
}
  1. Receive an error:
{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "failed to parse filter for alias [date_nanos_alias]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "failed to parse filter for alias [date_nanos_alias]",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "date[1969-12-25T23:59:59.999Z] is before the epoch in 1970 and cannot be stored in nanosecond resolution"
    }
  },
  "status" : 400
}

Activity

added
:Search/SearchSearch-related issues that do not fall into other categories
on Mar 27, 2020
elasticmachine

elasticmachine commented on Mar 27, 2020

@elasticmachine
Collaborator

Pinging @elastic/es-search (:Search/Search)

elasticmachine

elasticmachine commented on Mar 27, 2020

@elasticmachine
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

removed
:Search/SearchSearch-related issues that do not fall into other categories
on Mar 27, 2020
gaobinlong

gaobinlong commented on Mar 31, 2020

@gaobinlong
Contributor

This issue maybe originated from this line in MetaDataIndexAliasesService:

aliasValidator.validateAliasFilter(alias, filter, indexService.newQueryShardContext(0, null, () -> 0L, null),

nowInMillis is set to 0 in QueryShardContext.

jimczi

jimczi commented on Mar 31, 2020

@jimczi
Contributor

This is correct @gaobinlong thanks for looking. Would you like to provide a pull request to fix this since you already found the issue ?

gaobinlong

gaobinlong commented on Apr 1, 2020

@gaobinlong
Contributor

@jimczi I'm glad to do that.

added 2 commits that reference this issue on Apr 16, 2020
338798a
5267315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @cpitchford@gaobinlong@elasticmachine@jimczi

      Issue actions

        Unable to create filtered alias, using range, data_nanos and negative offsets(now-7d) · Issue #54315 · elastic/elasticsearch