Skip to content

Years and months units aren't supported for 'scale' parameter in decay score function #19619

@igorbunova

Description

@igorbunova

Elasticsearch version: 2.3

JVM version: 1.8.0_66

OS version: linux 3.2.0-106-generic-pae

Description of the problem including expected versus actual behavior:
The documentation says that date units expressions work for 'scale' parameter of the decay function, however not all date time units seem work.

As the user I expect an expression as '10y' or '10Y' work as '10 years'
Also I expect an expression as '2M' work as '2 month'.

Actually years pattern isn't supported and 'M' unit works as minutes.

There is a work-around to write '365d' instead of year and '30d' instead of month, however it will produce slightly different results if the current month has 31, 28 or 29 days or the current year is leap.
If years and months units can't be supported the documentation should have a complete list of supported units (now it isn't obvious)

Steps to reproduce:

  1. Create a mapping with the indexed date field
  2. Put some documents
  3. Perform the fuctional score query with any decay function on your date field and scale with year or month expression

Logs:
Caused by: ElasticsearchParseException[Failed to parse setting [GaussDecayFunctionParser.scale] with value [10y] as a time value: unit is missing or unrecognized]

(see the attachment for stack trace)
log.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search Foundations/MappingIndex mappings, including merging and defining field typesTeam:Search FoundationsMeta label for the Search Foundations team in Elasticsearchdiscuss

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions