Search in following user meta fields

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Search in following user meta fields

This topic contains 5 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 6 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #24305
    blaircodecanyon36
    blaircodecanyon36
    Participant

    The User Meta Fields documentation at
    https://documentation.ajaxsearchpro.com/general-settings/search-in-users/user-meta-fields
    does not match the user interface on the plugin.

    Moreover, despite entering user meta fields into
    General Options -> User Search -> Search in following user meta fields
    it will not return results for more than one meta field value at a time.

    Example of issue:

    User meta field 1 color: red
    Searching red returns all red users

    User meta field 2 size: small
    Searching small returns all small users

    BUT
    Searching red small returns No Results for “red small”!

    #24311
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    Thank you for noting the mismatch – the interface since had been updated to a more user friendly version, I have updated the documentation as well now.

    With the default search phrase logic, searching “red small” will only return users where either of the selected fields match “red” and “small”. If there is no overlapping, then using the “OR” logic might be the better choice: https://i.imgur.com/dUNDRux.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24338
    blaircodecanyon36
    blaircodecanyon36
    Participant

    Thanks for the reply.

    But if there is overlapping, for example a user named “JOE” that has a meta field for color = red, AND a meta field for size = small, I’m assuming searching red small will return that user.

    Presently,
    1- searching red returns JOE
    1- searching small returns JOE
    1- searching red small returns No Results for “red small”!

    #24345
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Interesting, I cannot seem to be able to replicate this fully. I have an idea though. Please try adding the following code to the functions.php file in your theme directory:

    add_action('asp_query_args', 'asp_query_args_meta_changes');
    function asp_query_args_meta_changes($args) {
      $args['user_search_meta_fields_separate_subquery'] = 1;
      return $args;
    }

    This should force a separate keyword logic for the meta queries in the user search.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24359
    blaircodecanyon36
    blaircodecanyon36
    Participant

    Well this works, however it slows the search down considerably.
    Too slow for production.

    #24363
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Well, this is the main reason this feature is programatically disabled. Each meta query needs to run as a sub query in order to check the individual fields per phrase. In smaller databases usually it makes no difference, but it exponentially slows down as it grows.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.