Closed (fixed)
Project:
Search API
Version:
8.x-1.10
Component:
Database backend
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Mar 2018 at 09:32 UTC
Updated:
18 Mar 2019 at 11:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
drunken monkeyThanks for reporting this problem!
However, I fear I cannot reproduce this, and we also have automated tests in place to ensure this works correctly.
Do you maybe have the "Parse mode" for the "Fulltext search" filter set to "Direct"? In this case, please try switching to "Multiple words".
Also, what server backend are you using?
PS: It seems you (like many others – it's really easy to misinterpret) are confused by the "Issue tags" field. As the guidelines state, they aren't meant for free text tags related to the issue, but only for specific categorization purposes, usually by module maintainers.
So, if you aren't sure your current usage is correct, please just leave the field empty.
Comment #3
drunken monkeyMarked two issues as duplicates, so this seems to be a more wide-spread problem than I thought. However, I still can‘t reproduce this, so I’ll need more information: used backend, entered keywords, minimum steps to reproduce (from clean installation) any displayed/logged errors, etc.
Comment #4
drunken monkeyWith the additional information in #3011084: Views Filter "Contains none of these words" doesn't work, I was finally able to reproduce this problem – it only occurs in conjunction with partial matching.
The attached patch should fix this, and contains test coverage to ensure this keeps working.
Comment #6
rauch commentedThanks for the patch. This fix the error message i reported on this issue.
But unfortunately the search works not in all cases. E.g. when there are multiple search filters.
Here is what works:
When I have multiple words connected with "and" or "or" then the search result is always empty:
Here is the Query from the views preview:
Comment #7
rauch commented@drunken monkey can you reproduce the problem I described above?
For Feedback, I would be very grateful.
Comment #8
drunken monkeySorry for the delay, I had a very busy December.
Yes, I could indeed reproduce the problem! After a bit of debugging, I luckily also found its cause: a re-used alias led to a wrong substitution resulting in unfulfillable conditions.
The attached revision for my above patch should resolve this problem, too. Please test/review!
Comment #9
legolasboThis introduces unneeded code duplication. I propose to move the nested query generation to before the if statement like so:
This is basically a dataprovider, lets make it official and actually put it in a @dataProvider :)
Comment #10
borisson_About #9.2. we've tried to be as mindful as possible about using d.o resources (and thus keeping test runs as fast as possible). You'll see other places where we do something similar, as we want to make sure we do the minimal amount of drupal installs as possible during the test runs.
That's we do things like this in browser tests.
This is a kernel test, so they are fast enough as is. I think the added readability of a dataprovider is a win here.
Basically a long-winded way of saying +1 ;)
Comment #11
rauch commentedThanks again for the patch. Now the search for multiple words connected with "and" and "and not" works (e.g. "lisa" and "max" and not "john").
But when I connect multiple words with "or" and "and not" (e.g. "lisa" or "max" and not "john") then the conjunction changes from "or" to "and".
@drunken monkey can you reproduce this behavior?
Comment #12
drunken monkey@ legolasbo: Thanks a lot for the thorough review!
I agree with your first note, that could really be written better. I tried it in the attached revision, please tell me what you think.
Regarding the second note: I generally agree, data providers are superior to just having the data sets inline, like I did in #8.
However, in this case, the problem is the nested loop, over both data sets and match mode. Converting this to a data provider would result in twelve data sets, with a lot of duplication, which not only subtracts a lot from the readability, but also takes considerable time to run: a bit over two minutes in my case (whereas the whole
testBackend()just needs 22 seconds). Kernel tests are still not as cheap as Unit tests, and the whole setup does take its time.Finally we currently have all regression tests as sub-methods of the main
testBackend()test method, so the proposed code in #8 is also more consistent with existing tests. (Though that’s the least important argument here.)I still changed the implementation to a data provider in the attached patch, but would advise against actually committing it in this state.
Do you set that with multiple “Search: Fulltext search” filters in the view, or with custom code?
Can you use the live preview’s “Show query” functionality to get the Search API query being executed for that view?
In general, combining multiple “Search: Fulltext search” filters doesn’t really work as it should, due to technical restrictions of the Search API architecture.
Comment #13
legolasboHmm, I've run the tests locally, both before, with #8 and with #12 and see your point about the time it takes to run these tests. I think we've got ourselves a bit of a conundrum here, where on one hand we can have optimum test accuracy and on the other hand have optimum test execution speed.
After having thought about it some more and a thorough look at how the tests operate I've come to the conclusion that the test actually tests 4 searches in 3 different configurations. The searches themselves don't change anything about the test setup and can therefore safely be preformed in the same iteration to safe resources. I therefore propose to have a simple dataprovider that only provides the match mode and then run the searches themselves within each iteration to reduce the number of test setups from 12 to 3 without the risk of the tests contamination each other.
Your other changes are fine by me :)
Comment #14
rauch commented@drunken monkey
Yes I do have multiple “Search: Fulltext search” filters in the view. I have three “Search: Fulltext search” filters. One for the operator "Contains all of these words", one for "Contains any of these words" and one for "Contains none of these words".
Here is the Query from the views preview for the search "lisa" or "max" and not "john" where I had inserted "lisa max" in the filter field "Contains any of these words" and "john" in the filter field "Contains none of these words".
Comment #15
rauch commentedIs there any chance to fix the problem from comment #11?
Comment #16
drunken monkey@ Keule: Ah, I see the problem now!
Please see #3031991: Fix edge case errors when combining multiple fulltext search filters in Views.
Comment #17
drunken monkey@ Legolasbo: Hm, really not sure. Half a minute of runtime just for a single issue’s regression testing still seems a lot to me. After all, this will run for every single patch posted for this module (in D8).
I also have to admit I generally don’t understand the “test accuracy” argument much. This will almost never fail, and when it does, it should still be easy to see why – or you can modify the test a bit at that point to see it more clearly. But doing all of this beforehand for a scenario that might never arise seems a lot like a variant of “premature optimization” to me.
@ Joris: What do you say, are you +1 on the compromise in #13 or do you also find half a minute too much?
In case we stick with this, the
$matchModeshould be changed back to snail_case, so this needs work regardless.Comment #18
borisson_Half a minute is a lot, but I think that the tests are more readable with the compromise in #13. I agree with the change back to snake(snail) case.
Comment #19
drunken monkeyAlright, then I’m washing my hands off this and will just direct the Test Bot Resources Police to your doors when they come knocking … ;P
Should be RTBC now?
Comment #20
borisson_Yes!
Comment #22
drunken monkeyAlright, thanks!
Committed.
Thanks again, everyone!