Problem/Motivation
The advanced search form for Node search lacks several features that make searching more difficult.
- Advanced search form is always collapsed, even if it was how you did the original search.
- The advanced search form is not populated with search values from previous searches or from the regular search.
- The regular search form is still shown to the user even if the advanced search form is being used.
- The regular search form stores the advanced search values in a complex form that is difficult to read and could be confusing to users. By hiding it, this problem would be solved.
I think that each of these issues can be addressed simply and would substantially improve usability. I would think that users perform more than one search when trying to find something refining or broadening the search as needed to find what they want. To do that effectively with the advanced search involves a lot more typing and mouse clicking to use, which makes it a big pain.
Proposed resolution
Fix the advanced search form so that after you submit it, values are prefilled.
Remaining tasks
Patch with tests has been made.
Get patch reviewed and committed.
User interface changes
Advanced search form, after submitting, will be filled with the values you submitted, like any other form normally is.
API changes
None.
Beta phase evaluation
Issue category | Bug because normally forms refill their values after you submit (for things like search anyway), and this one doesn't, so it's a usability issue. |
---|---|
Issue priority | Just normal. It's annoying, but you can fill in the form again if you have to. |
Prioritized changes | The main goal of this issue is a usability bug fix, so it is Prioritized |
Disruption | No disruption. Change is localized to the Node search advanced form's default values after submit, very localized.. |
Comment | File | Size | Author |
---|---|---|---|
#48 | 278958-45.patch | 11.19 KB | pwolanin |
#45 | increment.txt | 1.72 KB | pwolanin |
#45 | 278958-45.patch | 11.19 KB | pwolanin |
#31 | 278958-advanced-search-usability-test-only-FAIL.patch | 3.57 KB | jhodgdon |
#31 | 278958-advanced-search-usability-31-with-tests.patch | 10.76 KB | jhodgdon |
Comments
Comment #1
jhodgdonI just ran into this again today.
My suggestion would be to fix the node_search_form_alter() function in node.module() so that it addresses these issues, except I'm not sure #3 is so terrible if the other items are addressed.
I think this is actually a bug. If you use the advanced search form, the search form you see with the search results should look like what you submitted.
It shouldn't actually be all that hard to fix either.
Comment #2
jhodgdonHmmm...
Looking closer at the "advanced" search form, there are some problems with being able to populate the form values. The main problem is that in "advanced" search, you can enter or, phrase, or negative keywords, which are then added to the main search query like:
other keywords already present OR orword1 OR orword2 -negative1 -negative2 "phrase goes here"
The problem is that if those are put into the "advanced" search form, then you also need to take them out of the main search keywords box. I'm not sure if that is a great idea. Maybe it's OK if the advanced box is expanded so you can at least see what your search query was...
Thoughts?
Comment #3
jhodgdonI'm going to look into this today, with the goal of either making a patch or shoving it off to D8.
Comment #4
jhodgdonNote: I found a WTF in here. node.module processes taxonomy term filtering from advanced search, but it doesn't currently display a taxonomy term filter in the advanced search UI. I am adding some comments to the code so that this is at least a known factor in the state of the code. A contrib module could presumably add selected vocabularies to the advanced search form, and node.module would process them.
Comment #5
jhodgdonHere is a patch, which appears to be working well on my test box.
Since I don't have -up in my patching setup (Eclipse, sigh), I will just note that the first hunk is a code comment added to node_search_execute() (see #4 above), the last hunk is a code comment added to node_search_validate() (#4 again).
The rest is all added to the node_search_form_alter() function, which is where the advanced search form is built. This patch:
- Figures out which options/entries were made in the advanced search form to build the search keywords query string.
- Populates these as the current/default values for the advanced search form.
- Removes them from the keywords query string, so they don't appear twice
- Expands the advanced search form if anything was put in there, so people can see what search they did.
Note: we should also fix #987210: Language-specific searches should include language neutral content, which has implications for advanced searching.
Comment #6
jhodgdonwhoops, forgot the patch.
Comment #8
pwolanin CreditAttribution: pwolanin commentedThis looks like a significant change, though I see the benefit.
Minor nit - aside from the failing test, we can use the faster/simpler str_replace() instead of preg_replace() since we have the full match.
Comment #9
jhodgdonIt is definitely a significant change to the UI, and I think it's a significant UI improvement. The current state of the UI is a big WTF to a non-sophisticated user. They try an advanced search, and they get back their search encoded in a non-friendly way in the search keywords box, so they can't easily modify their search and try again. With this fix, they get back what they put in, so they can see what they are doing.
Good point about the str_replace, and there seems also to be a test failure that is real (a test that was apparently looking at the search query string shown on the screen).
Comment #10
jhodgdonre #8 - I guess we can use str_replace for the cases where preg_match_all() == 1 is tested. For the other cases, I don't think a loop over $matches[0] and using str_replace there would be more efficient than preg_replace? At least I think it wouldn't save much, and I would think the compiled preg_replace would be faster than a PHP loop. Not sure.
Given that this means one place would need to stay as preg_replace and two would change to str_replace, I am inclined to leave them all as preg_replace to make the code more consistent and easier to scan. If I used str_replace, I think I'd need to put in an explanation like // We verified there is only one match, and we have the whole matched string, so str_replace is more efficient. Thoughts?
Anyway, here's a new patch, with the test fixed.
I've also attached a screen shot of what this looks like, after selecting a bunch of stuff in the advanced search form and submitting. The advanced search form comes up expanded and filled in, just as you had it filled in when you submitted. Which is what a user would expect.
The second screen shot is what it looks like if you do the same advanced search without the patch (I've used Firebug to widen the search keywords form so you can see the full effect). The advanced search form comes up collapsed, and if you expand it, you'll see that nothing is filled in. Which is very confusing UI.
Comment #11
ombra82 CreditAttribution: ombra82 commented#6: 278958.patch queued for re-testing.
Comment #12
pwolanin CreditAttribution: pwolanin commentedNeed to fix in 8 first, or are we assuming we are going to eliminate the advanced search form in 8?
Comment #13
jhodgdonI don't see any work happening yet on getting a new search module for d8, so I think we should mark this d8 for now at least.
Comment #14
cpliakas CreditAttribution: cpliakas commentedJust throwing it out there, but maybe the advanced search form should be eliminated from core all together and handled in Contrib? I honestly have never seen anyone use the advanced search form, and often times modules such as Views are leveraged when advanced search like functionality is needed.
Comment #15
jhodgdonI'm not working on search any more, sorry (unfollowing too).
Comment #16
cpliakas CreditAttribution: cpliakas commented:-( Thanks for all of your invaluable contributions up to this point, though!
Comment #17
kscheirer#10: 278958-10.patch queued for re-testing.
Comment #18
kscheirerRetesting against latest HEAD since it has been over a year.
Comment #20
klonosI think we should postpone this on #2083717: Convert Search Results to Views (or close it as a duplicate or even make the other issue a META and this one one of its sub-issues).
Comment #21
jhodgdonNeed to look at this in 8 and see what's happening and how to fix it, if it is actually broken in 8?
Comment #22
MichelleIt does still need work in D8, especially in not having both the regular search and advanced search visible at the same time.
Comment #23
jhodgdonYes, it's still an issue in D8 and still should be fixed.
Comment #24
jhodgdonI am looking into this.
Comment #25
jhodgdonHere's a first pass at least. It does the following:
- If the user submitted the Advanced form, it opens up the form.
- It takes the information from the keywords string and puts it into the Advanced form.
I am not sure it is absolutely perfect, but I think it works. Let's see if it breaks any of the existing tests, and I'd still need to make a test for it.
No interdiff. Things have changed 'slightly' in 4 years and I started over.
Comment #27
jhodgdonActually setting back to needs work, since I forgot I need to write some tests for this. Still, if someone wants to (a) test it and (b) review the code/approach, that might be useful.
Comment #28
mgiffordThe trouble I had with the patch in #25 was that I kept entering keywords in the "Containing any of the keywords" just gets them plunked into "Enter your keywords" after hitting submit.
It doesn't make sense for me that it doesn't stay where you are expecting it to be.
I actually preferred the more cryptic combination of searches that was in the "Enter your keywords" as it shows how you the more complex searches you can do in a single line.
Great that the Advanced search remains open and that the other fields come pre-populated with what you entered though. Good step forward.
Comment #29
jhodgdonThanks for testing! So, the way it's supposed to work is the "any" keywords become the "OR" terms, so ... anyway, things shouldn't be moving back and forth. I'll have to check on this, maybe there's something wrong.
Regarding liking the cryptic format it does without this patch, well I think you're alone on that. :)
That said, if someone prefers that on a site, they can definitely just turn off the Advanced form though, and you are free to use the unique Drupal-specific cryptic format... which I think may also be documented in the Search Help now too.
Anyway, the way this patch is supposed to work, if you entered something in Advanced it opens the form and tries to put the stuff back in Advanced, but if you used the basic field it doesn't try to extract it to Advanced. And it should be consistent with what you did. I need to write some tests to make sure that is true, and I'll do some more manual testing as well.
Comment #30
jhodgdonRE #28, I tested this... What happens is that if you only put 1 word in the "Any" box, you aren't supplying alternatives, so it ends up in the main search box. If you want to have alternatives, you need to put at least two words into the "Any" box.
So for instance if in the main search box you have "cat", and then in Any you put "dog", you're asking for "Page contains both cat and dog" so the query becomes "cat dog" in the main search box.
But if you have "cat" in main and "dog fish" in Any, your query is "Page contains cat, and also either dog or fish". In this case, you get "at" in main and "dog fish" in the Any box, and the page title is "Search for cat dog OR fish".
Also by the way you do get to see what the "cryptic" query would be without the parsing out -- it is in the page title. ;)
Anyway, so I think the form is working correctly. If you still have problems, please provide details on the steps to reproduce so I can tell what you're seeing, but in my tests it is working right where it can.
So now I'm going to write some tests and upload a new patch. Finally. ;)
Comment #31
jhodgdonOK here's a new patch with a test. The interdiff is the test-only patch (I didn't make any changes to the previous patch's code, only added the test). Test passes locally.
Also updating the issue summary with template and beta eval.
Comment #33
jhodgdonPatches passed/failed as expected. A review would be lovely.
Comment #36
mgiffordThe Containing any of the words is still confusing. It does get transferred to Enter your keywords but I can't get the value I type to stick in Containing any of the words after submitting the form.
1 entry is logically a valid entry for any. Containing none of the words works fine for just one word.
Ultimately though, if you enter a word in Containing any of the words you expect it to be there after you hit submit.
That's my 2c.
Comment #37
jhodgdonThe problem is that there is no difference between "containing any of the words" with just 1 word, and typing that 1 word into the main search box.
Basically the "any" is an OR box. The main box is AND. But if you have only one word, there is no difference between AND and OR. So that is one UI flub: if you only type one word in the "any" box, it gets transferred to the main box. I really cannot do anything about that without a MAJOR rearchitecture and it is semantically correct for the search, even though I agree it could be confusing. It is way less confusing than it used to be when everything vanished, however!
Comment #38
jhodgdonI also disagree that 1 word is semantically OK for "any", or that it is semantically distinguished from typing that one word in the main search box. If you only type one word, it is not "any of these words".
Comment #39
pwolanin CreditAttribution: pwolanin as a volunteer and at Acquia commentedLooks like a nice addition to fill the form, and definite usability improvement.
Comment #40
Wim LeersLooks like it's not yet done, considering #36/#37/#38?
Comment #41
jhodgdonWell, the two maintainers of the Search module think it's done. It's a vast improvement in usability from the existing Search module, and probably all that we'll have time to do before 8.0.x.
Comment #42
pwolanin CreditAttribution: pwolanin as a volunteer and at Acquia commentedI agree - given that we are parsing the keywords back out of the single query param, it's not possible to distinguish that a single word was entered into one of the other boxes. i think having the search work is probably better than an annoying form error for this case.
Comment #43
Wim LeersOh, sorry, @jhodgdon — I misread your comment!
Comment #44
alexpottUnnecessary wrapping in ()
This ternary should be expanded as it is hard to read.
How about about changing this to
$query['form'] = ADVANCED_FORM
and makingADVANCED_FORM
a class constant - which is equal toadvanced
. T is pretty cryptic - I guess it stands for TRUE.Comment #45
pwolanin CreditAttribution: pwolanin as a volunteer commentedhow about this?
Comment #46
jhodgdonThe change looks good to me, and the tests still pass. I think all of @alexpott's concerns were addressed. Thanks!
Comment #48
pwolanin CreditAttribution: pwolanin as a volunteer commenteduh, bot sporadic fail? re-uploading patch.
Comment #49
pwolanin CreditAttribution: pwolanin as a volunteer commentedComment #50
alexpottCommitted 0623c09 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.
re-flowed comments to the 80 character width on commit.