# min\_age / max\_age filter not working correctly

**URL:** https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841
**Category:** Bug
**Created:** [2016 年 2 月 19 日午前 8:48 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841 "2016-02-19T08:48:54Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![Rene](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rene/32/115724_2.png) [@Rene](https://meta.discourse.org/u/Rene)
#### Post date: [2016 年 2 月 19 日午前 8:48 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/1 "2016-02-19T08:48:54Z")

</div>

Hey there,

in our forum ( [http://discuss.gradle.org](http://discuss.gradle.org) ) we’d like to filter for all topics with no replies older than a day or two. It seems that min\_age:1 is not respected when configured in a query. sample query:

> **[Search results for 'min\_age:2 status:noreplies order:latest' - Gradle Forums](https://discuss.gradle.org/search?q=min_age%3A2%20status%3Anoreplies%20order%3Alatest)**
>
> News, discussions & support

Am I missing something obvious here or can you acknowledge that this is a bug?

cheers,  
René

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016 年 2 月 19 日午後 4:56 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/2 "2016-02-19T16:56:24Z")

</div>

Are these the correct search querystrings, @sam?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016 年 2 月 19 日午後 5:32 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/3 "2016-02-19T17:32:37Z")

</div>

Not sure if this is a bug or just a contextual wording problem, but the query you want to use is

> **[Search results for 'max\_age:2 status:noreplies order:latest' - Gradle Forums](https://discuss.gradle.org/search?q=max_age%3A2%20status%3Anoreplies%20order%3Alatest)**
>
> News, discussions & support

That seems to do what you were wanting.

Looking at the code

> <https://github.com/discourse/discourse/blob/4be8de21a17a088946085b162c8ab4a652e9879a/lib/search.rb#L254-L262>

They seem to be doing the reverse of what they describe (depending how you look at it). min\_age is saying it has to be created after X days ago, and max\_age is saying it should be created prior to X days ago.

---

<div class="post-metadata">

### Author: ![Rene](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rene/32/115724_2.png) [@Rene](https://meta.discourse.org/u/Rene)
#### Post date: [2016 年 2 月 20 日午前 12:44 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/4 "2016-02-20T00:44:19Z")

</div>

thanks for clarifying. but this is quite confusing behaviour, isn’t it?

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2016 年 2 月 20 日午前 12:53 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/5 "2016-02-20T00:53:23Z")

</div>

> [@Rene](#):
>
> this is quite confusing behaviour, isn’t it?

Not to me, but I guess it’s

> [@cpradio](#):
>
> depending how you look at it

To me “min\_age” means “not newer than this” and  
“max\_age” means “not older than this”

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016 年 2 月 23 日午前 12:10 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/6 "2016-02-23T00:10:31Z")

</div>

I am open to changing the words here, its the second time it has tripped people. Any suggestions for better terms to describe this ?

`older_than` and `newer_than` ?

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [2016 年 2 月 23 日午前 12:16 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/7 "2016-02-23T00:16:38Z")

</div>

You know, I’ve been wondering the same thing, but I haven’t really come up with anything better than older\_than and newer\_than either.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [2016 年 2 月 23 日午前 12:18 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/8 "2016-02-23T00:18:08Z")

</div>

Maybe part of it is “lower” dates are older while “higher” dates are newer?

Maybe before and after?

A difference would be max and min are inclusive, but before and after are exclusive

“on or before”, and “on or after”, are a bit too wordy IMHO and not everyone would understand \<= \>=

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016 年 2 月 23 日午前 12:42 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/9 "2016-02-23T00:42:36Z")

</div>

`before` and `after` seem like nice clear simple words, what do you think @sam?

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016 年 2 月 23 日午前 2:11 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/10 "2016-02-23T02:11:01Z")

</div>

Issue with `before` is that it does not read right.

Slack allow for `before` but it is way more fancy … `before:june` , `before:yesterday` , `before:2016-02-17` all work there .

I guess we can go with `before` but add that support … should be fairly simple to support some basics there. localizing is very tricky though.

---

<div class="post-metadata">

### Author: ![Rene](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rene/32/115724_2.png) [@Rene](https://meta.discourse.org/u/Rene)
#### Post date: [2016 年 2 月 24 日午前 7:12 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/11 "2016-02-24T07:12:57Z")

</div>

Thanks to all of you for your support here.

I like this proposal `before:yesterday` or `before:2d` is what we’re looking for.

cheers,  
René

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016 年 3 月 14 日午後 12:45 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/12 "2016-03-14T12:45:33Z")

</div>

Ok this is now significantly simplified per

> [@Searching for posts created within a specific timeframe](https://meta.discourse.org/t/how-to-search-for-posts-within-a-timeframe/41011):
>
> bookmark This guide explains how to use Discourse’s search functionality to find posts created within a certain timeframe. person_raising_hand Required user level: All users Discourse’s search interface allows you to scope your searches to specific date ranges using the before and after search clauses. This feature can be particularly useful when you need to find posts from a certain period or within a specific timeframe. Using the before and after clauses The before and after clauses …

@Rene let me know what you think

---

<div class="post-metadata">

### Author: ![Rene](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rene/32/115724_2.png) [@Rene](https://meta.discourse.org/u/Rene)
#### Post date: [2016 年 3 月 15 日午前 10:03 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/13 "2016-03-15T10:03:55Z")

</div>

cool. Thanks again for the work on this. looks good to me.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2016 年 3 月 15 日午前 10:21 UTC](https://meta.discourse.org/t/min-age-max-age-filter-not-working-correctly/39841/14 "2016-03-15T10:21:26Z")

</div>


