Advanced Search problem


(Dungeon Mistress) #1

I need to search for posts after a certain period of time (in this case after October 1, 2016).

After going to the Advanced Search page, I enter what I want to search in the Search bar, click on “Posted” and change ‘before’ to ‘after’ - but when I try to put in the date, it just refreshes & clears the Search page. I’m not able to put in any date at all.

I’ve tried clicking on the date box and getting there by tabbing.

Am I doing something wrong?


(Vinoth Kannan) #2

I am unable replicate this problem here on meta and in AN Forums too. I successfully searched by using the advanced search panel here Search results for 'network after:2016-10-01' - AN Forums


(cpradio) #3

There is definitely a bug here. I can replicate it. I won’t be able to look into this today or tomorrow though.


(Dungeon Mistress) #4

For what it’s worth, I have the same problem in the Advanced Search here also.


(Vinoth Kannan) #5

interesting, still am unable to replicate :slight_smile:


(cpradio) #6

Repro steps

  1. Go to Advanced Search
  2. Type ‘testing’ in search field
  3. Change before to after in the Advanced Search UI
  4. Type in the mm/dd/yyyy (watch the search field at the top)

Definitely happens in Chrome, other browsers YMMV.


(cpradio) #7

Playing with it, it seems to be related to the use of Ember.run.debounce

In short, you can recreate this with the Minimum Post Count too. What is happening is if you key in the year or the minimum post count (greater than 9) very quickly, it registers it as two (or more) additional constraints, instead of one.

Why? Because due to Ember.run.debounce, it isn’t fully updating the component and thus doesn’t recognize that it already inserted the constraint.

I added a console log, got this output, which happens when you type in 11/01/2016 quickly.

discourse/components/search-advanced-options:493 match[0] = undefined
discourse/components/search-advanced-options:494 searchTerm =  before:0002-11-01
discourse/components/search-advanced-options:493 match[0] = undefined
discourse/components/search-advanced-options:494 searchTerm = before:0002-11-01 before:0020-11-01
discourse/components/search-advanced-options:493 match[0] = undefined
discourse/components/search-advanced-options:494 searchTerm = before:0002-11-01 before:0020-11-01 before:0201-11-01
discourse/components/search-advanced-options:493 match[0] = undefined
discourse/components/search-advanced-options:494 searchTerm = before:0002-11-01 before:0020-11-01 before:0201-11-01 before:2016-11-01
discourse/components/search-advanced-options:489 match[0] = before:0002-11-01
discourse/components/search-advanced-options:490 searchTerm = before:0002-11-01 before:0020-11-01 before:0201-11-01 before:2016-11-01

The fact that match[0] is undefined is due to Ember.run.debounce not invoking the _update call yet.

Any ideas @tgxworld?


(Vinoth Kannan) #8

For me it is “dd/mm/yyyy” (since am from india). So I am not getting that problem. Instead when I type the year manually I have search textbox like this testing after:0086-03-22 after:0019-03-22. But I typed 22/03/1986


(cpradio) #9

Exactly, same thing, you ended up with two entries in the textbox, hence the issue at hand. Now if you continue to try and update the year, it gets confused and fails. :slight_smile:


(cpradio) #10

Ugh, so once I started digging, I just couldn’t stop, this isn’t perfect and doesn’t fully prevent the problem, but it is far better

https://github.com/discourse/discourse/compare/master...cpradio:fix-advanced-search-speedy-entry?expand=1

There is likely a better way to take it though.


(cpradio) #11

PR Submitted that solves this issue entirely.

@tgxworld, I had to undo the lack of calling filter blocks routinely to fix this, as that was the reason for it failing majestically. This makes it 100% accurate as you type.


(Alan Tan) #12

@cpradio Let’s try this out. If there is any sluggishness, we’ll have to rethink the approach because it’ll be scanning the terms n times where n is the number of filters we have now.


(cpradio) #13

I did think of a possible other approach, I’m going to work on it, but it isn’t easy. One of those, when I woke up this morning, it hit me on another potential way of doing this, but whether it only works in theory or also in practice is yet to be seen. :slight_smile:

But if it works, it will put us back to not populating it all of the time.


(Alan Tan) #14

Actually we can try profiling it first, search terms are not very long so it might not be a big deal after all. :slight_smile:


(cpradio) #15

That’s good as my theory isn’t working well in practice. It still has all sorts of issues with the date input. :frowning:

https://github.com/discourse/discourse/compare/master...cpradio:performance-improvement-advanced-search?expand=1


(Dungeon Mistress) #16

I’m still having the same issue that I described in the first post. Any news about this?


(cpradio) #17

Can you describe the scenario better? As I don’t have a problem anymore. Do you have it on your site or here at meta?


(Dungeon Mistress) #18

I guess I don’t know how to explain it any better than I already have, but here goes.

I want to search for only items posted after a certain date (example: October 1, 2016)

After going to Advance Search Page:

I input the word(s) I want to search for in the search line - then I go down to “Posted” and click on “After” (see example below)

When I try to click on the date area, the screen refreshes and takes me right back to this page. I cannot enter or choose a date.

This is in my forum as well as here.


(Joshua Rosenfeld) #19

I had no issue doing that on your site:


(Dungeon Mistress) #20

I’m using Windows 10 / Edge, do you think that’s part of the problem?