Closed (fixed)
Project:
Search API
Version:
8.x-1.13
Component:
Views integration
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Jul 2019 at 01:14 UTC
Updated:
18 Jul 2023 at 13:58 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
NewZeal commentedPatch works for OR only. So nid+nid+nid will work same as nid,nid,nid.
Comment #3
NewZeal commentedFatal coding error in last patch. Try again.
Comment #4
drunken monkeyCould you please elaborate on how the current code “doesn't appear to work at all”? Maybe with some examples? The Views admin UI live preview should already give you a nice representation of the query, so maybe just show a comparison of what conditions are placed before/after your patch for some example arguments.
The code looks correct to me, that’s why I ask. (Though it does in any case seem like a good idea to use
INinstead of multiple conditions, for performance reasons.)Anyways, seems we desperately need some test coverage for this. Would you be able to provide one that shows how this currently doesn’t work, and that your patch fixes this?
Also, seems you forgot to rename
$keepin one instance.Comment #5
NewZeal commentedI'm using it in conjunction with search_api_solr, so it may be that this is the actual source of the problem. I spent some time trying to get it to work and it simply wouldn't. Try setting up a View using a solr index and the argument handler will not work with more than one tid.
Yes, it does look like $keep should be $query in the patch. The current patch works for our purposes for now.
Comment #6
onedotover commentedUpdating this patch to support both AND (tid,tid,tid) and OR (tid+tid+tid) queries.
Comment #7
borisson_This still needs tests (at least functional ones) to ensure that this keeps working but I think that this change makes sense, adding an IN operator for performance sounds like a good idea.
I'm not sure if we should do anything to Search API solr for this. @mkalkbrenner should know.
Comment #8
PaulDinelle commentedRan into this issue today, and Patch #6 cleared it up for me.
Since a scenario was requested, you can perform the following steps to reproduce.
Scenario:
When filter value is not available:
When filter value is available or default provided:
More:
Testing:
Expected behaviour:
Actual behaviour:
Comment #9
drunken monkeyThanks a lot for the detailed description! I was now easily able to reproduce this, and confirm that this is a problem. (Though it’s a long way away from “doesn't appear to work at all”, of course – but yes, we want to support multi-value arguments with both conjunctions.)
The attached is a cleaned-up version of the patch in #6 (also thanks a lot for that!), which works fine for me, too, and should also cover a few special cases. Please test/review to make sure this still works as intended.
However, with the code getting more complex we should also definitely have test coverage, so this is still needed before we can commit.
Comment #10
drunken monkeyForgot to attach the patch.
Comment #11
drunken monkeyHm, OK, thinking about it a bit more, the “no field found for term” logic didn’t quite make sense. Should be better this way. (But this is exactly why we need tests! With examples, this is much easier to understand.)
Comment #12
PaulDinelle commentedRerolled patch #11 for 8.x-1.16. Minimized a couple lines of code to use inline-IFs since they were simple checks and values.
Any chance we can get this committed for next release? I see we're just missing the tests. Can anyone take the use-case I provided in #8 to write some tests?
I'm not set up for test automation atm, and likely won't have time to do so for quite a while due to scheduling.
I have verified this issue exists and patches #11 & #12 fix the issue consistently for their respective module versions. If someone could submit tests so we could get this patched that'd be stellar!
Comment #13
drunken monkeyThanks for the re-roll, and the suggested small changes! However, please provide an interdiff when making actual changes (apart from the re-roll) so it’s easier to see what you changed.
While the inline
?:condition makes sense in the first case, the second one with two variables being set is probably clearer when kept in an actualif. No big difference either way, in any case, and mostly just taste.The
@varline of course definitely makes more sense immediately before theforeach, thanks for that!The other two changes seem more accidental – specifically, the one seems to indicate you don’t have your editor/IDE set to UTF-8, which could cause a lot of hard-to-detect problems.
Anyways, as you say, tests are still needed.
Comment #14
niles38 commented@drunken monkey, your patch worked for me! Thank you so much!
Comment #15
drunken monkeyThanks for the feedback, niles38!
Well, it took more or less a whole day, but I now got tests working for this so we can finally commit it.
Please test/review!
Comment #17
drunken monkeyCommitted.
Thanks again, everyone!
Comment #19
trickfun commentedI have the same error with 8.x-1.29 version
I can't apply the patch.
When i run the query with taxonomy term ID = 26, i get this:
No term ID inside the query.
While the title of views changes correctly based on the ID.
Thank you
Comment #20
-Kirill- commentedI have the same error with search-api version 8.x-1.29, Drupal 9.5.9, any ideas please?
Comment #21
phma commentedEnded up here for the same reason. Looks like a regression which was fixed here, but hasn't been released yet #3354906: Regression in Views argument plugins (date and all terms): https://git.drupalcode.org/project/search_api/-/commit/9faec4590e48d8add...