How do you store a date that represents the end of time?

I am indexing a document with an expiration date field that I use as a filter when querying for search results.

A document can either have a date or not, and I'm looking to filter by documents whose expiration is greater than today (i.e., in the future). When there is no expiration date for a document, what should I put as the value for the expiration date in the index? I was thinking something like '9999-12-31' (December 31, 9999) but that is really ugly. There are only gt, gte, lt and lte options on the range filter.

I was thinking of storing null in the field, but am having trouble with OR/AND'ing multiple filters because the expiration date must be in the future OR non-existent AND must match other parameters.

Any ideas?

Can I just say that this thread title wins.

Hi @jamilnyc,

I'd suggest not adding the expiry field at all for these documents and then using a an exists query in a bool must_not clause (ES >= 2.x) or a missing query in older ES versions. Something like:

{
    "bool" : {
        "must_not" : {
           "exists" : { "field" : "expiry" }
        }
    }
}

Thanks! For simplicity we decided to go with a future date. But I like storing the boolean field idea. I think I'll still give it a try.