Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cpitchford opened this issue Mar 27, 2020 · 5 comments · Fixed by #54785
Closed
Labels
>bug :Data Management/Indices APIs APIs to create and manage indices and templates

Comments

@cpitchford
Copy link

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
}
@jimczi jimczi added :Search/Search Search-related issues that do not fall into other categories >bug labels Mar 27, 2020
@elasticmachine
Copy link
Collaborator

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

@jimczi jimczi added the :Data Management/Indices APIs APIs to create and manage indices and templates label Mar 27, 2020
@elasticmachine
Copy link
Collaborator

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

@jimczi jimczi removed the :Search/Search Search-related issues that do not fall into other categories label Mar 27, 2020
@gaobinlong
Copy link
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
Copy link
Contributor

jimczi commented Mar 31, 2020

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
Copy link
Contributor

@jimczi I'm glad to do that.

cbuescher pushed a commit that referenced this issue Apr 16, 2020
…led (#54785)

Modify the value of nowInMillis in queryShardContext to current timestamp, because the
value will be used lately when validating the filtered alias which uses now in a date_nanos
range query.

Closes #54315
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this issue Apr 16, 2020
…led (elastic#54785)

Modify the value of nowInMillis in queryShardContext to current timestamp, because the
value will be used lately when validating the filtered alias which uses now in a date_nanos
range query.

Closes elastic#54315
yyff pushed a commit to yyff/elasticsearch that referenced this issue Apr 17, 2020
…led (elastic#54785)

Modify the value of nowInMillis in queryShardContext to current timestamp, because the
value will be used lately when validating the filtered alias which uses now in a date_nanos
range query.

Closes elastic#54315
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Data Management/Indices APIs APIs to create and manage indices and templates
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants