• Resolved poikilos

    (@poikilos)


    I am not sure how providing more information will help. Simply update to the latest version of WordPress (I have automatic updates), install ACF: Better Search using the defaults, then do a search. There are no results. The issue occurs with any word, regardless of case or symbols. Searching works when I deactivate the plugin.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @poikilos,

    Thank you for your message. First of all, I am asking you for patience – I do it out of passion in my free time, so please be patient.

    I will try to help you, but I need some extra things from you:

    1. Screenshot of your search results (entire browser window).
    2. SQL query displayed after change in plugin code (https://gbiorczyk.pl/img/8jYkbzF.png) when you try to search for something.
    3. ID of post you want to find.
    4. Screenshot of the edit page of the post you want to find (show the fields in which they are values that can not be found).
    5. Screenshot of the edit page of ACF Fields Group that is used in this post (show the fields in which they are values that can not be found).
    6. Version of ACF plugin and version of ACF: Better Search.
    7. Database dump (only table wp_posts and wp_postmeta tables). Please delete private data from it, if any.

    @mateuszgbiorczyk I’ve experienced the same issue’s and have been running the created query directly on my MySQL server and see the following issue(s)

    This part in the SQL query is causing some issue’s (it’s not giving errors, but the results are blank:

    (b.meta_id IS NOT NULL)
    AND (c.ID IS NOT NULL)

    So the b.meta_id is always NULL in my case & so is c.ID for some reason, however, the a.meta_value below does work & I found the following stackoverflow thread about using aliases inside the where-clause and that that could cause issue’s!

    Stackoverflow Thread

    Changing that part to the following:

    (a.meta_id IS NOT NULL)
    AND (wp_posts.ID IS NOT NULL)

    will fix the issue for me, I have locally adjusted the code inside acf_better_search/app/Search/Where.php lines 60 & 61 and that seemed to fix the issue for me. According to the stackoverflow the other aliasses shouldn’t work, but somehow they do. I also see that you join the same table twice (post_meta) but my SQL-query skills aren’t that good, so I don’t fully understand why they are joined twice…?

    The full query that was being constructed just to give some more context:

    SELECT DISTINCT SQL_CALC_FOUND_ROWS  wp_posts.*
    FROM wp_posts
    
    LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
    INNER JOIN wp_postmeta AS a ON (a.post_id = wp_posts.ID)
    LEFT JOIN wp_postmeta AS b ON ((b.meta_id = a.meta_id + @@auto_increment_increment) AND (b.meta_key LIKE CONCAT('\_', a.meta_key)))
    LEFT JOIN wp_posts AS c ON ((c.post_name = b.meta_value) AND (c.post_type = 'acf-field') AND ((c.post_content LIKE '%:"text"%') OR (c.post_content LIKE '%:"textarea"%') OR (c.post_content LIKE '%:"wysiwyg"%')))
    
    WHERE 1=1
    AND ( wp_term_relationships.term_taxonomy_id IN (7) )
    
    AND (
    	(
    		(b.meta_id IS NOT NULL)
    		AND (c.ID IS NOT NULL)
    		AND (a.meta_value LIKE '%Microsoft%')
    		AND (a.meta_value LIKE '%Azure%')
    	)
    	OR (
    		(x
    			(wp_posts.post_title LIKE '%Microsoft%')
    			OR (wp_posts.post_content LIKE '%Microsoft%')
    			OR (wp_posts.post_excerpt LIKE '%Microsoft%')
    		)
    		AND (
    			(wp_posts.post_title LIKE '%Azure%')
    			OR (wp_posts.post_content LIKE '%Azure%')
    			OR (wp_posts.post_excerpt LIKE '%Azure%')
    		)
    	)
    )
    
    AND wp_posts.post_type = 'cpt_jobs'
    AND ((wp_posts.post_status = 'publish'))
    GROUP BY wp_posts.ID
    ORDER BY wp_posts.post_date
    DESC LIMIT 0, 9
    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Thank you very much for your tests. Please send me the database dump I requested.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @poikilos and @stijnd, please download the latest version of the plugin and try using Incorrect Mode in the plugin settings. This should solve your problem.

    Please let me know if you have any problems.

    Wordpress 5.4
    Server architecture Linux 3.12.18-clouder0 x86_64
    Web server Apache
    PHP version 7.3.15 (Supports 64bit values)
    Extension mysqli
    Server version 5.7.25-28-log
    Database host localhost
    Database charset utf8mb4
    Database collation utf8mb4_unicode_520_ci

    Changing to incorrect mode works for me, but nothing else does.
    Thanks for the work on this!

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @trothmaster, In that case, it means that you have a disordered structure in the database. Nothing can be done about it. Thanks to Incorrect mode for search works and is the only solution. You do not have to worry about.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘The search has no results.’ is closed to new replies.