Home › Toolset Professional Support › [Resolved] incorrect search results–intermittent problem
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 |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 24 replies, has 3 voices.
Last updated by Minesh 2 years, 10 months ago.
Assisted by: Minesh.
I am trying to: I searched for a Spanish speaking counselor who specializes in marriage and is located within a 25 mile radius of 33173. This search pulled 27 counselors with several counselors out of state.
Link to a page where the issue can be seen: hidden link
I expected to see: 1 counselor found in multiple locations
Instead, I got:
I have a view for searching and displaying the results with a map, and the
search includes a "within X miles of location". Most of the time, this works
fine. However, sometimes I've seen results that were far outside the location
range. I've been able to determine that when this happens, the URL the browser
requested was correct, including the relevant toolset_maps_distance_radius,
toolset_maps_distance_unit, and toolset_maps_distance_center parameters. When
I look at the javascript console, I can see the actual SQL query, and when it
fails, the SQL query does NOT include ST_Distance_Sphere in the where and order
by clauses. When it works, it's in both. Additionally, when it fails, "OR
wp_posts.post_status = 'private'" is added to the where clause, which I believe
would include any private posts, instead of only the published posts.
To be clear, here's a sample URL for both success and failure:
hidden link
This is the SQL query logged when it works:
wpv_filter_get_posts] SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_postmeta AS tmapsmeta ON ( wp_posts.ID = tmapsmeta.post_id )
LEFT JOIN wp_toolset_maps_address_cache ON wp_toolset_maps_address_cache.address_passed = tmapsmeta.meta_value
WHERE 1=1 AND (
wp_term_relationships.term_taxonomy_id IN (723)
AND
tt1.term_taxonomy_id IN (653)
) AND (
wp_postmeta.meta_key = 'wpcf-address'
) AND wp_posts.post_type = 'yyyy' AND ((wp_posts.post_status = 'publish'))
AND ST_Distance_Sphere(ST_PointFromText('POINT(-80.360297 25.7038331)'), wp_toolset_maps_address_cache.point) < 40233.6
GROUP BY wp_posts.ID ORDER BY ST_Distance_Sphere(ST_PointFromText('POINT(-80.360297 25.7038331)'), wp_toolset_maps_address_cache.point) ASC
This is the SQL query logged when it fails:
wpv_filter_get_posts] SELECT wp_posts.* FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id) LEFT JOIN wp_term_relationships AS tt1 ON (wp_posts.ID = tt1.object_id) INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id )
INNER JOIN wp_postmeta AS tmapsmeta ON ( wp_posts.ID = tmapsmeta.post_id )
LEFT JOIN wp_toolset_maps_address_cache ON wp_toolset_maps_address_cache.address_passed = tmapsmeta.meta_value
WHERE 1=1 AND (
wp_term_relationships.term_taxonomy_id IN (723)
AND
tt1.term_taxonomy_id IN (653)
) AND (
wp_postmeta.meta_key = 'wpcf-address'
) AND wp_posts.post_type = 'yyyy' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private'))
GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value ASC
Please note I replaced some values with xxxx or yyyy, but they are exactly what
I expect and are the same for both failure and success cases.
Any ideas what might be causing this seemingly random failure? I haven't found
any customized code that attempts to change the query, so it appears to be a
bug in toolset?
Hello. Thank you for contacting the Toolset support.
With the both query you shared I see one query that works has the Toolset Maps address cache entry:
wp_toolset_maps_address_cache.point) < 40233.6
And the query that fails does not have the above line.
Can you please go to Toolset => Settings => Maps tab => Cached data section => Click on the button "Check for missing cache entries" Ad then check if that adds any missing cache table entry and check if that help you to resolve your issue.
Thank you for the information. Checking for missing cache entries shows 13 were missing, and 13 were processed (I assume that means the missing cache items were added to the cache?). However, we've still been able to reproduce this problem. Please note that the original queries were for the same search location, and the same URL. That was even using the same web browser, just at different times.
Thanks!
I would like to know a bit of site history. Are you imploring or did you imported the data to the site?
Can you please share problem URL where I can see the issue and admin access details?
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Hello;
Unfortunately, we will not be able to provide you with admin access to our site. You have both the problem URL and selection criteria to reproduce this intermittent error. Please let us know next steps. Thank you.
Hello,
Minesh is currently on vacation at the moment so I will be handling the issue here.
Unfortunately none of the URLs that you've shared gives me a link to the actual page with the issue.
Can you provide the link so that I can look at the search itself.
Thanks,
Shane
Hi Shane;
The sample URL above can be reproduced by going to the "Link to a page where the issue can be seen" URL and entering the following criteria:
Search 25 mile radius of zip code = 33173
Add a filter for Languages = Spanish
Add a filter for Specialties = Marriage
Intermittently the results will display 27 counselors with several counselors out of state. Thanks!
Hello,
I've been testing the search but so far i'm only getting the results in my screenshot.
Only one location appears.
Hello Shane;
Thanks for looking into this. Our results were intermittent where at times the erroneous result set appears all the time and at other times it's difficult to reproduce. It may be best to look at the SQL above where one result is as we expect and the other is erroneous. The difference in the SQL that works has an additional
AND ST_Distance_Sphere(ST_PointFromText('POINT(-80.360297 25.7038331)'), wp_toolset_maps_address_cache.point) < 40233.6
GROUP BY wp_posts.ID ORDER BY ST_Distance_Sphere(ST_PointFromText('POINT(-80.360297 25.7038331)'), wp_toolset_maps_address_cache.point) ASC
whereas the result set that fails does not. That is the difference and we're not sure why a erroneous SQL is executed (without the distance filter). What is causing the wrong SQL to be executed?
Hello,
My first thought here is to ensure that the address caching isn't the issue. The same diagnoses Minesh made due to the cache entry. However given that you've already tried clearing the maps cache then there is no need for further checks there.
Is this a view created in Toolset Blocks ? Meaning it was the gutenburg editor that was used to create the view? If so then your view might also be caching. If you're using the View Block, please select it and then disable the cache toggle and let me know if the issue still remains.
Thanks,
Shane
Hello Shane;
I don't believe it was created by toolset blocks; we do have some views that show with "Block Editor" on the title, but this one does not. The person who created this site for us is no longer here. Can you give us more direction to get you the answer you need?
Hello,
If you go to Toolset -> Views are you able to edit this search view from this panel ?
Or is it that from the frontend when you edit the page you're able to edit the view on the page template itself. If you're able to edit the view from the page template then once you click the view you should be able to disable the caching in the block settings.
Thanks,
Shane
Hi Shane;
The view is editable from Toolset -> Views. It appears on multiple pages that are managed by Elementor, and appears on those pages via a shortcode.
Hello,
Can you try adding this parameter to the shortcode.
cached = 'off'
Thanks
Shane
We will test that change. Can you help us understand, though, what exactly that does (what cache is disabled?), and why it might fix an intermittent problem like this?
Thanks.