• Resolved Nolibert

    (@nolibert)


    I get the following error thrown when enabling the meta search feature:

    WordPress-Datenbank-Fehler:?[Not unique table/alias: 'bsq_meta']
    SELECT DISTINCT (MATCH(wp_posts.post_title) AGAINST ('opera' ) * 10 ) + (MATCH(wp_posts.post_content) AGAINST ('opera' ) * 1 ) as score FROM wp_posts LEFT JOIN wp_postmeta AS bsq_meta ON (wp_posts.ID = bsq_meta.post_id) LEFT JOIN wp_postmeta AS bsq_meta ON (wp_posts.ID = bsq_meta.post_id) WHERE 1=1 AND ( wp_posts.post_date <= '2024-07-16 15:35:56' ) AND ((MATCH(wp_posts.post_title) AGAINST ('opera' ) * 10 ) + (MATCH(wp_posts.post_content) AGAINST ('opera' ) * 1 ) OR ( ((wp_posts.post_excerpt LIKE '%opera%') OR (bsq_meta.meta_value LIKE '%opera%')) ) ) AND (wp_posts.post_password = '') AND wp_posts.post_type IN ('post', 'page', 'video') AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'inherit')) ORDER BY score DESC LIMIT 0,1

    this error gets displayed two times on the search page, then this error appears:

    WordPress-Datenbank-Fehler:?[Not unique table/alias: ‘bsq_meta’]
    SELECT SQL_CALC_FOUND_ROWS DISTINCT wp_posts.*,wp_posts.ID as ID, (MATCH(wp_posts.post_title) AGAINST ('opera' ) * 10 ) + (MATCH(wp_posts.post_content) AGAINST ('opera' ) * 1 ) as score,wp_posts.ID as ID, (MATCH(wp_posts.post_title) AGAINST ('opera' ) * 10 ) + (MATCH(wp_posts.post_content) AGAINST ('opera' ) * 1 ) as score FROM wp_posts LEFT JOIN wp_postmeta AS bsq_meta ON (wp_posts.ID = bsq_meta.post_id) LEFT JOIN wp_postmeta AS bsq_meta ON (wp_posts.ID = bsq_meta.post_id) WHERE 1=1 AND ( wp_posts.post_date <= '2024-07-16 15:35:56' ) AND ((MATCH(wp_posts.post_title) AGAINST ('opera' ) * 10 ) + (MATCH(wp_posts.post_content) AGAINST ('opera' ) * 1 ) OR ( ((wp_posts.post_excerpt LIKE '%opera%') OR (bsq_meta.meta_value LIKE '%opera%')) ) ) AND (wp_posts.post_password = '') AND wp_posts.post_type IN ('post', 'page', 'video') AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'inherit')) ORDER BY (MATCH(wp_posts.post_title) AGAINST ('opera' ) * 10 ) + (MATCH(wp_posts.post_content) AGAINST ('opera' ) * 1 ) DESC LIMIT 0, 10

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

    (@ajay)

    @nolibert

    I can see what the error is but unsure why this is coming through. Are you able to give me screenshots of the settings page? You can upload these on imgbb if needed. There is something that is causing the left join twice which I am not sure why.

    Thread Starter Nolibert

    (@nolibert)

    Hi Ajay,

    here you go:

    https://ibb.co/6FHRYwy
    https://ibb.co/zXy96g1
    https://ibb.co/8BFtry2
    https://ibb.co/9rzP7K3

    The Site is using Elementor for the styling of the search results which works fine when meta fields are not enabled.

    Thanks!

    Plugin Author Ajay

    (@ajay)

    I just tried to simulate this with your settings – with “Search meta” enabled and disabled but can’t get the error.

    I assume you’re getting this error only when you have search meta enabled?

    One thing to check is if you install Query Monitor, it should throw up an error as you have above and in there it gives you the call stack. Wondering if that will help us trace where this came from albeit unlikely as it is a few WordPress filters that cause this to happen.

    Do you have a list of plugins you are using? Wondering if there is clash there. I’m not sure if this could be an elementor issue. I checked the free version and I don’t think that allows me to change the search template.

    Thread Starter Nolibert

    (@nolibert)

    Hi,

    i did some digging on my own, looks like the error comes from the the aliases beeing included two times. The plugin has two ways of registering filters and hooks, the file class-better-search.php on line 125 triggers the hooks() method if seamless mode is true and if we are in a main query. Looks like Elementor triggers this to be true for some reason. I commented out line 125 and im getting the search results now.

    Edit: I saw that this option was the seamless integration option on the first settings page. I deactivated this and now it works without any code mods. ??

    here is the Stack

    1. Better_Search->set_topscore()
      wp-content/plugins/better-search/includes/class-better-search.php:1006
    2. apply_filters_ref_array('posts_clauses_request')
      wp-includes/plugin.php:256
    3. WP_Query->get_posts()
      wp-includes/class-wp-query.php:3089
    4. WP_Query->query()
      wp-includes/class-wp-query.php:3852
    5. WP_Query->__construct()
      wp-includes/class-wp-query.php:3984
    6. ElementorPro\M\Q\C\Elementor_Post_Query->get_query()
      wp-content/plugins/elementor-pro/modules/query-control/classes/elementor-post-query.php:68
    7. ElementorPro\M\Q\Module->get_query()
      wp-content/plugins/elementor-pro/modules/query-control/module.php:962
    8. ElementorPro\M\P\W\Posts->query_posts()
      wp-content/plugins/elementor-pro/modules/posts/widgets/posts.php:73
    9. ElementorPro\M\L\W\Base->query_posts()
      wp-content/plugins/elementor-pro/modules/loop-builder/widgets/base.php:57
    10. ElementorPro\M\P\S\Skin_Base->render()
      wp-content/plugins/elementor-pro/modules/posts/skins/skin-base.php:908
    11. ElementorPro\M\L\S\Skin_Loop_Base->render()
      wp-content/plugins/elementor-pro/modules/loop-builder/skins/skin-loop-base.php:123
    12. Elementor\Skin_Base->render_by_mode()
      wp-content/plugins/elementor/includes/base/skin-base.php:79
    13. Elementor\Widget_Base->render_content()
      wp-content/plugins/elementor/includes/base/widget-base.php:633
    14. Elementor\Widget_Base->print_content()
      wp-content/plugins/elementor/includes/base/widget-base.php:776
    15. Elementor\Element_Base->print_element()
      wp-content/plugins/elementor/includes/base/element-base.php:483
    16. Elementor\Element_Base->print_content()
      wp-content/plugins/elementor/includes/base/element-base.php:1422
    17. Elementor\Element_Base->print_element()
      wp-content/plugins/elementor/includes/base/element-base.php:483
    18. Elementor\Element_Base->print_content()
      wp-content/plugins/elementor/includes/base/element-base.php:1422
    19. Elementor\Element_Base->print_element()
      wp-content/plugins/elementor/includes/base/element-base.php:483
    20. Elementor\C\B\Document->do_print_elements()
      wp-content/plugins/elementor/core/base/document.php:1875
    21. Elementor\C\B\Document->print_elements()
      wp-content/plugins/elementor/core/base/document.php:1800
    22. ElementorPro\M\T\D\Theme_Document->print_elements_with_wrapper()
      wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php:412
    23. Elementor\Frontend->get_builder_content()
      wp-content/plugins/elementor/includes/frontend.php:1158
    24. Elementor\C\B\Document->get_content()
      wp-content/plugins/elementor/core/base/document.php:1249
    25. Elementor\M\L\D\Library_Document->get_content()
      wp-content/plugins/elementor/modules/library/documents/library-document.php:76
    26. ElementorPro\M\T\D\Theme_Document->get_content()
      wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php:158
    27. ElementorPro\M\T\D\Theme_Document->print_content()
      wp-content/plugins/elementor-pro/modules/theme-builder/documents/theme-document.php:173
    28. ElementorPro\M\T\C\Locations_Manager->do_location()
      wp-content/plugins/elementor-pro/modules/theme-builder/classes/locations-manager.php:364
    29. ElementorPro\M\T\C\Locations_Manager->ElementorPro\M\T\C\{closure}()
      wp-content/plugins/elementor-pro/modules/theme-builder/classes/locations-manager.php:240
    30. Elementor\M\P\Module->print_content()
      wp-content/plugins/elementor/modules/page-templates/module.php:207
    • This reply was modified 4 months, 1 week ago by Nolibert.
    Plugin Author Ajay

    (@ajay)

    Thank you for the detailed debugging. Unfortunately, I can’t yet test with pro elementor, however what you’ve done makes sense to me. Are the outputs as you expect them with seamless disabled?

    Thread Starter Nolibert

    (@nolibert)

    Yes everything works great now! Thank you ??

    • This reply was modified 4 months ago by Nolibert.
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.