Having an unlimited number of responses causes a large number of matches to be returned, particularly if the user types the first few letters slowly.
Option 1: Pick a limit. 10 seems reasonable.
Option 2: Default a limit in a variable, but provide no UI for setting the variable.
Option 3: Pick a default and put it in a variable. Maybe be global or content-type specific (pending resolution of that issue)
I favor option 3. For me, this issue is a show-stopper.
Also: extra credit: query n+1 and add an ellipsis after the nth entry if there are more. In this way the user knows that the list is not exhaustive.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | 942632-2-limit-responses.patch | 20.94 KB | danchadwick |
| #4 | 942632-1-limit-responses.patch | 17.64 KB | danchadwick |
Comments
Comment #1
danchadwick commentedComment #2
danchadwick commentedRelated to this is the number of characters entered before a match starts. Right now, the native node search does 1, the Drupal search does 3, and I'm not sure what solr does. Further, the Drupal search generates errors with less than 3.
As part of this issue, I plan to increase the number of characters typed before searching starts to 3. Currently the code deletes the matches when there are 0 (unless prepend is on) and matches when there are >0 characters.
I propose:
0: delete the results
1-2: leave results as they are
3: match
I could see the logic in deleting the results for 1-2, though. Anyone have any thoughts on this?
Comment #3
danchadwick commentedIn working on this, I've expanded the scope of issue. I plan to offer a patch for comment which:
- Triggers search upon page load, providing eliminating duplicate effort in PHP and fixing a bug with duplicate content
- Limits results to N; queries on N+1 and adds "... and more" after the item list
- Starts out with the inline fieldset collapsed, and expands it if there are matches. Block is unchanged.
- Replaces message inside field set with "success" message if there is no duplicated content and title exists
My focus is on the "replace contents" option. I'm unsure of the use case for "prepend, and am unsure of the desired behavior, so definition and/or work will be needed for that.
My goal is to provide a coherent upgrade to giving good interactive feedback without warning the user unnecessarily.
Comment #4
danchadwick commentedThe attached patch is relative to:
It incorporates functionality from Enhanced functionality when title is empty versus matching versus unique.
I have tested the cases of most interest to me: node searches, in-line widget, replace results. I have done some testing for prepend, but since I'm not sure of the use case, there may be corrections needed. I have tried to not introduce bugs for features I'm not using (i.e. solr, prepend, block widget, and taxonomy search), but I'm not sure that the features I've introduced are implemented either fully or correctly for these other cases. This is not because I don't care, but either because I'm not sure what the desired behavior is (prepend and taxonomy in particular) or because I don't have the ability to code and test (e.g. solr). Also, some of these features may be abandoned (unsure).
Please consider this patch for comment. I assume that other users may want things implemented differently or may find defects. If the patch is largely satisfactory, it may be most efficient to commit it (or a revision) so that other contributors can start with it as a base for their revisions and further work.
Comment #5
danchadwick commentedReply to bforchhammer from Enhanced functionality ... thread:
However I prefer separate patches ...
[The uniqueness in-line fieldset starts out collapsed.] ... Not sure I agree with your use case
Duplicate-results bug?
Needs to be implemented for Solr, definitely needs configuration option.
... and translation support ... make separate issues
That 10 search result limit with Drupal needs a note ...
See #899480: Configurable search content types if you haven't already.
Thanks very much for stepping up as co-maintainer. I look forward to working with you. If you start by committing your first three patches, I can re-roll my two to apply serially without offset or fuzz. Flexible URLs should be committed before this patch.
Comment #6
bforchhammer commentedThank you Dan, there's a lot of good work in your patch!
There are few things I would do differently though, and some things I don't quite understand. I guess some features really are rather intertwined but considering that it's not clear to me why some changes have been made I'd really like to see this split up into smaller pieces. Please understand that I'm not trying to make your life harder but sincerely think that splitting it up will lead to better code.
Also, even if some features are intertwined others can probably still be developed in parallel, like for example the four "User Interface" issues listed in #4. I will try to review and commit things quickly to avoid unnecessary hold-ups.
I'll go through the patch later today and provide some comments.
Comment #7
bforchhammer commentedI think I'd like the default to be UNIQUENESS_SCOPE_CONTENT_TYPE which seems the most sensible choice to me from a user's perspective.
Browser cache may keep this setting from taking effect right away.
Limit the number of search results. (Must be 10 or fewer if using "Drupal Search").
Help text being displayed above the list of results within the widget.
The number of results must be between [...]
Also, no need for the unescaped version; use @upper instead of !upper.
In my use case search results need to appear for 1 character only as well. I use the module with a database of clients which are often abbreviated with short 2 or three letter codes (e.g. HP, BP, BMW, SAP, ...).
Can we move $type and $nid into the $values array? ("type" and "nid" should fit nicely next to "title" and "tags").
Powered by Dreditor.
Comment #8
danchadwick commentedThanks for the review.
1) I too prefer having content-type be the default scope. I only suggested "all" for compatibility. I'll change it.
2) I just moved the block, but I'll fix the grammatical error. ;)
3) Good improvement, but would be even better if condition were put first. In this way, the user can determine whether the sentence relates to him/her without having to read the whole thing. So maybe:
Limit the number of search results. (For "Drupal Search", must be 10 or fewer.)
4) Also good, but I don't think it is help text and "being" implies action without providing more info. Maybe:
Heading displayed above the results within the widget.
5) Thanks for catching the "be". There is, however, no need for sanitizing a numeric value calculated in the line above. ! is the correct placeholder, I believe.
6) I think we need an option. If <3, then there is a bug with Drupal Search because a stream of errors will be displayed on the next page load, generated by the core search routine. In my use case typing a letter causes tons of results.
7) I considered where to communicate type and nid. I decided that the values array is best used to communicate the query specs from what the user typed -- what is needed based upon what the user did. The type and NID are static within one page, and would seem to be best conveyed in the URL. They could also go in the session, but I think that may be undesirable. (I'm no expert, but I have been reading that anonymous sessions may interfere with high performance caching. While node editing isn't usually anonymous, it could be.) Absent a good reason to change, I think it is implemented appropriately.
Comment #9
bforchhammer commented3) The comma in the middle seems a bit odd to me, but then I'm not a native speaker... Nothing I'm going to argue about. ;-)
4) I wouldn't call it a heading ("Related content" would be the "heading" for me, but we're talking about the "signal-to-noise-ratio text", right?);
6) Yes, and I guess this depends on the search type; there's no problem having < 3 characters when using node-title search. Instead of an option we could maybe just set it to 3 for drupal-search and 1 for node-title search... (?)
7) The reason I brought it up is because it changes quite a few function interfaces, makes them more specific and implies that nid and type are required for the execution of the search. I think of the $values array as the array of search parameters (which nid and type can be counted as) and I'd like to leave the decision on which parameters to use for a search up to the respective search method.
Comment #10
danchadwick commented3) The comma is optional after the prepositional phrase, but helpful for separation and corresponds to a natural pause when said aloud. The comma should probably go inside the quotes as required by proper punctuation rules, though. (Often this isn't done in computer use because the quoted text may be something that should be typed literally.)
4) I think the default "signal-to-noise" text should go, but I let someone else tend to that if they want. To me, it is a heading introducing exactly what is below. When used with the collapsed fieldset. the text is hidden when you start, displayed when you're in an "invalid" state with duplicates, and then replaced with the "Success!" message. Maybe:
Explanation displayed within the widget before the list of duplicates.
Or "Introduction displayed ..."?
6) I strenuously don't want it for < 3 characters for node title. If I want this, I bet other users will too. I think an option is in order.
7) I'll move the search specs to the values array. Of course, it could be "q=CONTENT-TYPE/NID". j/k
Comment #11
danchadwick commentedThis patch incorporates the feedback from above.
N.B. Depends upon current head + 941944-2-add-edit.patch (aka Flexible URLs).
Comment #12
bforchhammer commentedOkay, so as I said before this contains some really good changes, but I want to do things right which means I won't commit something is incomplete (solr), has a number of unclear/unresolved issues (fieldsets, minimum character number, possible translation/themeing issues) and is still largely untested. I'd rather keep the code base nice and clean instead of fixing bugs afterwards (as far as possible).
@coltrane, please feel free to override me on this if you feel that we should just go ahead with it... (after all I'm still learning the ropes as a module maintainer.)
Comment #13
danchadwick commentedAs far as I can tell, there are only three people who can test this -- the three active contributors. I have this patch deployed on my live site at Kindred Cocktails. You are welcome to create an account and create a test cocktail. Please delete it when you are done. And of course, you folks can install the patch for your own use and test it.
I can easily resolve the translation issues if you tell me how you want to proceed.
If you tell me you want to customize the fieldset starting state, I'll include that. I think our use cases are different because in my use I can't imagine wanting it visible in its initial state -- rather like putting up a warning sign for something that hasn't happened yet.
Clearly we both need different settings for minimum characters, so I think that is resolved.
As for Solr, I simply can't implement it. If no one else is going to implement it, I can validate the inimplemented setting combinations, but this is putting in code to go the wrong direction (which would be implementing it).
Since this is pre-release, I think we would be far better off with this patch (and flexible URLs) as a basis for polishing off any remaining issues. I'm not saying you shouldn't test it, but that it moves the module much closer to something that is universally useful to a larger audience.
Comment #14
danchadwick commentedI have added:
<span ...>from default success message, since user can now enter anything they want.I will re-roll once the translation patch (in whatever form it takes) and flexible url patches are committed.
Ben - would you be willing to implement the new features for solr -- limiting the number of responses, eliminating the current node from the results, and matching on content type?
Benedikt - would you be willing to look at the above patch to see if the collapsed fieldset meets your needs?
Comment #15
danchadwick commentedOnce 948442-translation is committed, I will rework the patch for this issue to:
1) Incorporate the theming changes from 948442.
2) Move the generation of the inline fieldset into the theming function to offer complete user flexibility for the inline HTML. They can start the field set out collapsed, expanded, or omit it entirely, all without having to complicate the admin UI further.
3) This patch already addresses the issue of generating the initial content for node-edit form and removes the server-side related content list generation, which fixes the theming differences between what the JS generates and what the drupal PHP theme generates.
Comment #16
ronald_istos commentedHi - have been trying to follow on work here and would suggest that it may be useful to break issues up into separate patches - or at least try and provide as much order as possible. You seem to be dealing with a lot of things in a single issue and it is making it hard to keep up with what is in, out, still being discussed.
Having said this - thanks for all the great work and expect patches from me tomorrow!
Comment #17
danchadwick commentedThe patch represent work begun 3-4 patches ago and not yet committed. Much of the changes are interrelated, dealing with the same (or nearly same) lines of code. Read the patch and you'll see.
Comment #18
ronald_istos commentedHi Dan - thanks for the explanation. Have been working with this module and applied the patch today which covers a lot of the basic needs, which is fantastic to see!
I would like to help on some of the other issues - could I suggest that you commit this patch, close this issue and then we can open up issues for the individual bits of works that remain as described in #14 - I would be happy to help re-roll any other patches myself (e.g. translation issues) to deal with the updated code.
Just seems to me that that would offer new users of the module a much better experience and would allow those who want to commit patches to focus on specific issues.
Comment #19
coltrane@ronald_istos, DanChadwick doesn't have commit access to the Uniqueness project and this issue is currently in "Needs Work" pending #15
Comment #20
bforchhammer commentedIf it helps, I have just posted a summary of the problems/features which are currently being discussed in our "meta issue": http://drupal.org/node/887880#comment-3723062
Comment #21
danchadwick commentedI haven't updated the batch because there isn't consensus on at least one feature. If we get agreement, then I can update the patch accordingly.
This patch eliminates the server-side content generation, relying on the Javascript for all list theming. The advantage is that a) the work is done only once -- less code / more reliable / simpler and b) the generated HTML is guaranteed to be identical between the two cases (initial page load versus interactive). The disadvantage is that the functionality is lost for non-JS user agents, such as screen readers.
We could do it all in the client, revert to list theming in both the server and client, or we could do it all in the server.
If we do it all in the server, there is a complication of keeping the list of already-processed nodes to prevent duplicates for the prepend case (from AJAX request to AJAX request). There would also be the option to send more strings to the client from the theme function. Some strings aren't initially visible. These could possibly be sent with inline CSS to hide them. The client would then extract the DOM elements, remove the CSS, and use them as needed. (This technique could also be used for the other implementation strategies as well.)
Continuing in this vein, the entire work of output generation could be moved to the server, with the client just sending the query (title) and getting fully-formatted HTML block content or inline content (including fieldset, for example). This would put more work onto the server and might be slower. It would have the advantage of putting all the logic that one might want to customize, and all the strings, into the theme function so that a theme developer could adapt it. It would remove the need to have some of the lesser-needed options in the admin UI. (The "Searching..." string comes immediately to mind.)
If it is a requirement that we support non-JS user agents, then something has to change. Speaking only for myself, I am OK with requiring JS because I feel this feature is helpful but non-essential functionality. However, obviously the maintainers need to set the requirements.
Note: I have two nearly back-to-back weeks of vacation coming up, so I don't expect to have much time in the next 3 weeks or so.
Comment #22
danchadwick commentedI now have an immediate need for multiple appearance settings -- one for each content type. These settings are the ones in the fieldset in the patch above. This provides the ability to have prompts and text that is specific to the content type.
I suggest that the global settings be left as above, and a checkbox added to the settings for each content type to the effect of "override global uniqueness settings" (so similar). This would enable and expand a fieldset below containing the same settings. Then the code would be refactored to use the content-specific setting if override is enabled for that content type.
This will be a fair bit of editing of the code as the settings are scattered here and there. However, I'm working on a fork since the above patch has not been committed. If there is a road map, I can work toward it. If my needs have diverged from others, I can simply continue in the fork, with the possibility of future merging harder and/or less likely.
If the above patch is OK to commit with the following changes, I will make them:
1) Reinstate the PHP theming so that javascript-less clients can see the duplicated content list.
2) Document which features do not work with SOLR. Since I think SOLR will eventually be implemented, I suggest this be in a readme or install.txt file, rather than code itself.
Comment #23
bforchhammer commentedSorry for being rather inactive for the past months; university work is taking priority for me at the moment...
I have now started splitting this up so we can at least move forward on things which we are agreeing on anyway:
#899480: Limit search to same content type
#1062642: Limit number of responses
#1063188: Minimum length of search string
Comment #24
danchadwick commentedI appreciate the effort to cherry-pick this patch and commit portions of it. When this is complete and committed, we can see if there are any remaining tidbits of meat on the carcass worth including, commit them, and then use that as the basis for future work, such as custom settings (including prompts) per content type.
Comment #25
bforchhammer commentedI think most bits have been committed now... The only remaining issue I'm aware of is #942654: Enhanced functionality when title is empty versus matching versus unique. I am closing this issue now. Feel free to create new tickets if I've missed something.