Skip to content

Nest.Time string convertion error for "month" #1880

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

Closed
jcaspes opened this issue Mar 2, 2016 · 1 comment
Closed

Nest.Time string convertion error for "month" #1880

jcaspes opened this issue Mar 2, 2016 · 1 comment

Comments

@jcaspes
Copy link

jcaspes commented Mar 2, 2016

Hi,

With Elasticsearch.Net 2.0.2.0 and Nest, the Time string convertion do not work for "month" like specified in documentation here: https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units

Here the results from console i have for each documented units:
(new Nest.Time("1y")).Milliseconds give: 31536000000
(new Nest.Time("1M")).Milliseconds give:1 ==> only 1 milliseconds for 1 month !!
(new Nest.Time("1w")).Milliseconds give:604800000
(new Nest.Time("1d")).Milliseconds give:86400000
(new Nest.Time("1h")).Milliseconds give:3600000
(new Nest.Time("1m")).Milliseconds give:60000
(new Nest.Time("1s")).Milliseconds give:1000
(new Nest.Time("1ms")).Milliseconds give:1

Other strange thing, When i use "2M" to define TTL on my mapping it result to a TTL of 120000 (2 minutes), here the code:

esClient.CreateIndex("MyIndex", index => index
    .Mappings(mapping => mapping
        .Map<MyType>(m => m
        // TTL Configuration
            .TtlField(ttl => ttl
                .Enable(true)
                .Default("2M")
            )
        )
    )
);
@gmarz gmarz added Bug labels Mar 2, 2016
gmarz added a commit that referenced this issue Mar 2, 2016
@gmarz gmarz mentioned this issue Mar 8, 2016
@gmarz
Copy link
Contributor

gmarz commented Mar 10, 2016

@jcaspes This is now addressed in #1881

To be clear though, new Time("1M").Milliseconds will now be -1. We can't accurately calculate milliseconds for months or years since their lengths may vary (30 vs 31 days or 366 vs 365 days). We would opt to make Milliseconds nullable instead, but that would be a breaking change.

In regards to the second part of this issue (setting ttl to 2M) is also fixed (via 116b117).

@gmarz gmarz closed this as completed in d103a6b Mar 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants