Skip Navigation

[Gelöst] Custom Search round-off issue

This support ticket is created vor 5 Jahren, 11 Monaten. There's a good chance that you are reading advice that it now obsolete.
Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Dieses Thema enthält 0 Antworten, hat 1 Stimme.

Zuletzt aktualisiert von Kostas vor 5 Jahren, 11 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#1177025

I am trying to: Perform a custom search and narrow search results.

Link to a page where the issue can be seen: At versteckter Link, if you press the search button (ΑΝΑΖΗΤΗΣΗ) you get 5 results. If now try to narrow down by setting "Οξύτητα" (second slider from top, and last column of results) to say 0:0.4 you expect to find 2 result, instead you find 4 results.

After installing "Query Monitor" plugin I found that the relevant query is:

SELECT wp_posts.*
FROM wp_posts 
INNER JOIN wp_postmeta
ON ( wp_posts.ID = wp_postmeta.post_id ) 
INNER JOIN wp_postmeta AS mt1
ON ( wp_posts.ID = mt1.post_id ) 
INNER JOIN wp_postmeta AS mt2
ON ( wp_posts.ID = mt2.post_id ) 
INNER JOIN wp_postmeta AS mt3
ON ( wp_posts.ID = mt3.post_id ) 
INNER JOIN wp_postmeta AS mt4
ON ( wp_posts.ID = mt4.post_id ) 
INNER JOIN wp_postmeta AS mt5
ON ( wp_posts.ID = mt5.post_id )
WHERE 1=1 
AND wp_posts.ID NOT IN (142)
AND ( ( wp_postmeta.meta_key = 'wpcf-blend'
AND CAST(wp_postmeta.meta_value AS SIGNED) = '0' ) 
AND ( mt1.meta_key = 'wpcf-quantity'
AND CAST(mt1.meta_value AS SIGNED) BETWEEN '0'
AND '50' ) 
AND ( mt2.meta_key = 'wpcf-oleicacid'
AND CAST(mt2.meta_value AS SIGNED) BETWEEN '0'
AND '0.4' ) 
AND ( mt3.meta_key = 'wpcf-fruity'
AND CAST(mt3.meta_value AS SIGNED) BETWEEN '0'
AND '10' ) 
AND ( mt4.meta_key = 'wpcf-bitter'
AND CAST(mt4.meta_value AS SIGNED) BETWEEN '0'
AND '10' ) 
AND ( mt5.meta_key = 'wpcf-pungent'
AND CAST(mt5.meta_value AS SIGNED) BETWEEN '0'
AND '10' ) )
AND wp_posts.post_type = 'oliveoil'
AND ((wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'private'))
GROUP BY wp_posts.ID
ORDER BY wp_posts.post_date DESC

I think that the CAST function for example here:

...CAST(mt2.meta_value AS SIGNED)...

rounds-off the number to the nearest integer and that is the culprit.
Should it be something like (?):

...CAST(mt2.meta_value AS DECIMAL)...

Please check it out.

Thank you,
Kostas

#1177027
#1177028