When I do not enter a search term, all results appear. This is desired behaviour.

When I enter a search term greater than the minimum word length of my database server, I get my "no results text" that I set in views. This is desired behaviour.

When I enter a search term shorter than the minimum word length of my database server, I get all results. This is not what I want. I want it to show that there are no results for this search.

I'm using search_api_db with views.

For now I have fixed this by setting the minimum word length to 1, but I shouldn't have to.

#6 1961120-6--views_minimum_keyword_length.patch2.48 KBdrunken monkey
PASSED: [[SimpleTest]]: [MySQL] 298 pass(es).
[ View ]


Version:7.x-1.4» 7.x-1.9
Issue tags:+affects Drupal.org

Happening to us on D7 Drupal.org as well. Search API 7.x-1.9. See issue #2118545: /project/issue/search returns results on two-character results.

OK, I see that with Views this doesn't even show a warning that words were ignored, which is of course bad. So one thing is, we should definitely fix Views to resolve this, i.e., (provide a way to) show any keywords that were ignored. Either by always outputting them (like the errors) or by providing an area handler listing them. (Or is it possible to just supply it as a token for area handlers, so users could just use a custom text?)

For displaying no results if no keys were present, we have several options. One question is whether this should always be the case – if so, then just fixing the database backend to do that seems like the proper solution. If this should be optional, the question is whether we should include the option for the server or for the view. For the server, the implementation would be cleaner and easier, but in the view it would allow finer-grained control (since different views could be configured differently). So it depends how likely you think it is that someone would want to display all results, and whether there would likely be anyone who wants this for some but not all searches.

The way D6 D.o shows warnings now is good: error message saying that user didn't input enough characters and the search field highlighted.

Only local images are allowed.

I don't think it's very likely that someone would want to display all results when searching for word shorter than minimum word length. That's confusing as the results displayed won't have any relation to whatever the person was searching for.

Version:7.x-1.9» 7.x-1.x-dev
Component:Framework» Views integration

Hm, for that to work (without larger hacks), I think we'd have to include that as an additional option for the "Search: Fulltext search" filter. Otherwise, there's no real/clean way to show a validation error for the field. Would that be OK? (I.e., that you'd have to set the same minimum word length on both the search server and the Views filter.)

That'd be ok I think. In fact I was looking for a setting exactly there, while trying to figure out how to fix that on git7site :)

Status:Active» Needs review
new2.48 KB
PASSED: [[SimpleTest]]: [MySQL] 298 pass(es).
[ View ]

OK, that should be easy. Patch attached, please test/review!

Applied the patch on my dev site, updated the view and it works just fine.
(User/pass drupal/drupal to access)

Issue summary:View changes
Status:Needs review» Fixed

Thanks for testing, good to hear it works!

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Active

So we have Search API with this patch on D.o, but it seems validation still isn't working for words shorter than minimum word length. Please, see this comment: https://drupal.org/comment/8614065#comment-8614065