Home › Toolset Professional Support › [Resolved] AJAX Search showing incorrect behaviour in Search Filters
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
Tagged: Custom search, Views plugin
Related documentation:
This topic contains 17 replies, has 3 voices.
Last updated by Nigel 3 years, 6 months ago.
Assisted by: Nigel.
Hi Support
We have noticed while testing recently that the search functionality appears to have changed in the search filters.
Whilst the search RESULTS remain correct, the search FILTERS are showing incorrect behaviour. I'll try to explain with an example.
We have a number of Ads under Find a Job Search and Results View.
hidden link
They can be filtered using, for example, the taxonomy "TYPE OF WORK". When I click one of the options "Occasional Native Nanny", the search correctly finds the only Ad which has this taxonomy term assigned. All other search filters update themselves correctly. So far so good.
However, there are no Ads containing ALL OTHER options from the TYPE OF WORK taxonomy, but these checkboxes are remaining clickable. The other options in our example should disappear for the user, because there are no records in the database that would match all terms of the taxonomy. (see screenshot)
Another example, click "Spanish" under "OTHER LANGUAGES" in the Search filters. There is one Job Ad found, but the only language on that Job Ad is Spanish, therefore the remaining languages should no longer be clickable under "OTHER LANGUAGES"
We are seeing similar incorrect behaviour in Find a Native Nanny as well:
hidden link
Did this incorrect behaviour crop up in the last plugin update perhaps?
Kind regards
Simon
Did this incorrect behaviour crop up in the last plugin update perhaps?
Hello, it's possible this was introduced in the Blocks 1.5.3 release, but I haven't seen any similar reports just yet. There was a known issue resolved in the latest release, related to the feature you are describing:
https://toolset.com/errata/view-setting-show-only-filter-options-that-would-produce-results-not-working-correctly/
However in these erratum cases, the filters showed up incorrectly upon page load, and manipulating a filter after page load actually produced the appropriate results. So it is possible that some edge cases were not fully resolved, and the problem is now obvious on your site for certain taxonomy filters.
I'll need to dig a bit deeper to find out. Is it okay for me to create a clone to run more tests locally where I can monitor the DB and code execution?
Hi Christian
Yes, I had come across that post too. But I think that option is only available when you are programming the View with Block Editor? At least I haven't seen that Boolean toggle option anywhere in the normal Toolset > Views > open some view in the "Classic" editor.
Is it the case that that option is indeed only available for Block Editor and not Classic Editor?
Of course you may take a copy, feel free to use Duplicator Pro on our site with the Default Storage option, otherwise you won't be able to access the files created.
Thanks and good luck in your research!
Kind regards
Simon
Is it the case that that option is indeed only available for Block Editor and not Classic Editor?
Actually no, this option is also available in the classic Editor. It is only visible when you choose the option "Let me choose individual settings manually" in the Custom Search Settings section.
At first glance, it seems this taxonomy filter is implementing an "OR" relationship between terms instead of an"AND" relationship between terms, because I can select both "Part-time" and "Occasional" for Type of Work and see 3 results, as opposed to 1 result when I select only "Occasional".
3 results:
hidden link
1 result:
hidden link
Of course you may take a copy, feel free to use Duplicator Pro on our site with the Default Storage option, otherwise you won't be able to access the files created.
Thanks, I'll give you an update before the close of my shift today.
Just a quick update to let you know I've had some trouble getting a clone of the site to run in my local environment successfully, so I'm asking another supporter to take over here.
HI Christian
I haven't made any changes to that search filter in a long time - it has always, and still is, using AND not OR. One thing that has occurred to me looking at the search filter is that the "Modes of Transport" filter seems to be broken somehow. There are no buttons to edit it or remove it or look at what is filtering. Perhaps the issue is somehow related to that? (see screenshot)
The same is in both Views Find a Job Search and Results View and Find a Native Nanny Search and Results View
I tried to edit the Mode of Transport filter in the text window as well, and I can enter the dialogue box, but when I accept any changes, it just remains the same...
I then tried to remove it via the text editor, which it did. It asked me if I wanted to remove it from the search filter (recommended). which I did too, but still it is "stuck" without any controls to manipulate it in the query filter.
Kind regards
Simon
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Hi Simon
Christian is on vacation, just to let you know I'm looking into this. On my own test site I don't seem to be getting the expected results, so I'm setting up a new clean site to test this issue specifically, and to see if the behaviour has changed with recent plugin updates.
I'll get back to you with the results a little later.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
On my test site it appears to be working correctly after all, and the behaviour hasn't changed recently, it works the same now as it did with a version from a few releases ago.
Namely, for the taxonomy where a term has been selected, all terms of that taxonomy continue to be displayed while at the same time other filters update to only show options that would produce results. I guess that is to facilitate changing the selected option for another one in the same filter.
But looking at what Christian shared before, it doesn't necessarily appear to be working correctly on your site, plus when editing Views some of the filters appear broken (i.e. are ineditable).
So I'm taking a copy of your site to install locally, where I can look into that further.
HI Nigel
Sure, you can use the Duplicator Pro with the Default Storage option.
Apologies if things are a bit messed up at the moment - we have had it to the back teeth with Avada and are in the process of transitioning from Avada to Astra theme and Elementor page builder.
Currently we are still using Avada, which is the theme we were testing against.
Kind regards
Simon
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
Sorry, re-reading your original post, that is the behaviour you were questioning.
That is intended, it is how it is supposed to work, and it hasn't changed recently.
Checking an earlier version on the local copy of your site gives the same results.
The rationale is indeed to avoid confusion where, for example you have chosen Spanish and want to change and choose French instead. It may not be obvious that to expose French it would be necessary to first uncheck Spanish, so the options for the filter you are applying are left intact.
Hey Nigel
1) Regarding issue 1 with the search results
I have to take you at your word that it was the same in recent versions, but myself and my colleague could have both sworn it was behaving differently previously (not sure how many versions back).
I feel that in its current state it is actually MORE confusing:
If I'm only interested in finding a Nanny who speaks French AND Spanish as OTHER LANGUAGES, then I would intuitively want to click both boxes.
If I choose Spanish first and there are NO Nannies who speak Spanish and one other language, then I would expect all the other boxes to disappear.
If I choose Spanish first and there ARE Nannies who speak Spanish AND another language, then those remaining languages should be presented in the checkboxes (and the results).
Every user nowadays who uses Filters in any major website (eg Amazon, Lufthansa) would expect the same behaviour.
This will lead to confusing results for the user and unnecessary scrolling or pagination through the result set if it is large. For example, with the current Ads we have in Find a Native Nanny:
if I click Spanish in OTHER LANGUAGES first, then French, I am presented with 4 matching Ads, however I should be presented with none, since no Nanny has OTHER LANGUAGES = Spanish AND French.
Moreover, Nannies who speak French and German in OTHER LANGUAGES are being presented, which doesn't even contain my first choice of Spanish.
2) Any ideas why Modes of Transport is still ineditable?
Kind regards
Simon
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
When you add multiple filters you can specify if they should be jointly evaluated with AND or OR, but an individual taxonomy filter is always evaluated with OR (actually, in the underlying query with IN).
So if you choose French and Spanish (or Spanish then French) in the Other Languages filter that will bring up results that speak French OR Spanish as a second language.
If your intention is to only show results that match both rather than either, there isn't such an option available within the UI for that.
The solution would require modifying the underlying query using the wpv_filter_query API hook (https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query), such that you change the IN comparison to AND for the taxonomy query.
Here's a basic example that converts ALL taxonomy queries in that View to work that way which you can use as a starting point:
add_filter( 'wpv_filter_query', 'ts_filter_query', 101, 3 ); function ts_filter_query( $view_args, $view_settings, $view_id ){ if ( $view_id == 2145 ) { if ( isset( $view_args['tax_query'] ) ) { $tax_queries = $view_args['tax_query']; foreach ($tax_queries as $key => $tax_query) { $view_args['tax_query'][$key]['operator'] = 'AND'; } } } return $view_args; }
Regarding the problem editing the query filters, which View should I be looking at? It appears fine in the Find a Native Nanny Search and Results View (screenshot).
HI Nigel
I'll have to look into the first issue in more details tomorrow, I'm working on another project today. However regarding the 2nd issue with Modes of Transport: Your screenshot is what I would expect to see, however this is what I see for both views "Find a Job Search and Results View" and "Find a Native Nanny Search and Results View". (see screenshots).
In both cases there is not way for me to edit it (changing it or re-adding in the text area didn't work either) and it appears differently.
Kind regards
Simon
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
It looked fine on my test site, but I'd disabled all but the essential plugins to check the other issue.
Re-activating the plugins I can see a similar problem on my local copy, so I'll see if I can work out which plugin is causing the problem.
Languages: English (English ) Spanish (Español )
Timezone: Europe/London (GMT+00:00)
That's proving tricky.
De-activating the plugins in turn didn't fix the issue, for which I had to deactivate and reactivate Toolset Blocks itself. And having re-activated all of the plugins in batches, the issue hasn't re-appeared.
So some other steps must be involved in producing the problem. I will keep investigating.