Problem/Motivation

When using Advanced Search on a Node search page, you have to enter keywords even if there are other valid search conditions chosen. You shouldn't have to.

See also
#487764: Allow wildcards like * in search
which had a similar original request but has been changed to be an issue about supporting wildcards in the keyword field (because wanting wildcards in searches is a common feature request).

Proposed resolution

Make it so that you do not have to enter keywords in order to search, if there are other conditions present.

Remaining tasks

Patch with test.

User interface changes

Users will be able to use Advanced Search for things like taxonomy and node type, without entering keywords.

API changes

The search query will support searches without keywords.

Original report by pwolanin

Late in the 7.x cycle we added the notion of non-keyword search conditions. Seems like we didn't quite finish that patch.

Search module for either the search block or main search form will print the error 'Please enter some keywords.' even if the module implementing the search hooks has satisified some conditions and will run a search.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pwolanin’s picture

one option for the search page is to add another param to the search_form function - otherwise we always have to call the conditions callback 2x

pwolanin’s picture

Status: Active » Needs review
FileSize
5.07 KB

have to put the conditions flag into the form as a hidden value due to the fact that we skip the conditions callback while processing the POST...

jhodgdon’s picture

Status: Needs review » Needs work

A few mostly minor issues with the patch:

a) Typo at the end of this line:

+ *   Optional extra search conditions supplied by a conditions callback.1

b)

+  // Conditions is stored as hidden, since search_view() always passes in an empty
+  // value when there is POST data.
+  $form['conditions'] = array(
+    '#type' => 'hidden',
+    '#default_value' => (bool) $conditions,
+  );

I think it should be a #type = 'value' not 'hidden' here? 'hidden' adds it to the form that is rendered, where 'value' makes it all behind the scenes and is what is normally used to pass information around in forms, right?

c) Why remove all those blank lines from the code? I think they were reasonable to keep...

d)

+    $conditions= NULL;

Needs a space before the =

e) Do we need a test for this?

Albert Volkman’s picture

Status: Needs work » Needs review
FileSize
4.35 KB

Not sure about tests, but here is a re-roll for 8.x.

Status: Needs review » Needs work

The last submitted patch, respect_conditions-1126688-4.patch, failed testing.

pwolanin’s picture

Issue summary: View changes
pwolanin’s picture

jhodgdon’s picture

You actually don't need to put the "related" field on both issues. If you put it on one, it shows up on the other. :)

jhodgdon’s picture

Issue summary: View changes

Made a better issue summary.

Albert Volkman’s picture

Version: 8.x-dev » 7.x-dev

This appears to be resolved in 8.x after the form conversion. Moving back to 7.x.

Albert Volkman’s picture

FileSize
4.36 KB

Re-roll for 7.x (still needs work).

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev

Um. I kind of disagree here. The only reason it is "working" in D8 is that the "please enter some keywords" text is not being displayed at all, as far as I can tell.

I am only seeing the "please enter some keywords" when searching from the search block, but it isn't happening from /search/node.

jhodgdon’s picture

I filed a separate issue for the missing "please enter some keywords" message in D8 and we should wait to test this again until that is fixed.
#2170411: Please enter some keywords message has vanished

jhodgdon’s picture

Status: Needs work » Postponed

We need to redo how errors and warnings are handled in searching on #1366020: Overhaul SearchQuery; make search redirects use GET query params for keywords, which will hopefully take care of this problem for 8.x anyway, so I'm postponing this until that one is done.

Albert Volkman’s picture

Yep, you're totally right. Sorry for the oversight.

jhodgdon’s picture

Category: Bug report » Feature request
Status: Postponed » Needs work

After working on that other issue for a while... I've decided this one can be un-postponed.

But we need to decide what to do about it.

The idea that is currently in the issue summary is to make it possible to search nodes with no keywords entered at all. That is not going to be resolved by the patch in #1366020: Overhaul SearchQuery; make search redirects use GET query params for keywords. That issue will make sure that you can do a search by entering either a phrase or some "or" words in the Advanced search box, but you will still need to enter at least one "positive" keyword for the search query to work, as it is currently written.

So if we want to allow someone to search by, for instance, just taxonomy and node type, we would need to revise how the search query is built (it can't be a query based on the {search_index} table if there are no keywords to match).

As such... it's really a feature request.

jhodgdon’s picture

Title: Search module prints 'Please enter some keywords.' even if conditions for search are met » Allow users to use advanced search without keywords entered
jhodgdon’s picture

Version: 8.0.x-dev » 8.1.x-dev

Since 8.0.x-beta1 has been released, our policy at this point is No feature requests until 8.1.x. See #2350615: [policy, no patch] What changes can be accepted during the Drupal 8 beta phase?. Sorry, it's just too late for 8.0.x at this point, so even if we had a viable patch, the core committers would not commit it.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.