This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

User Search and Multiple Keywords

Home Forums Product Support Forums Ajax Search Pro for WordPress Support User Search and Multiple Keywords

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #20327
    lrrmlrrm
    Participant

    Hi there,
    I have a question about the user search. I have a lot of users with a lot of data, address data and some serialized lists. If I search for an item in a list everything is alright. But if I combine a keyword with an for instance address there are no results. Could it be that this user search just looks for one term?

    Thanks!

    #20334
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi!

    With the exception of BuddyPress XProfile fields, all keywords are individually ‘searched’ within each field with each logic. I guess you might be using buddypress fields in this case?
    I am not sure if I can change that within the code, mostly because of performance reasons. You could try changing the search logic to ‘OR’, that will give you more results than the default logic though.

    #20339
    lrrmlrrm
    Participant

    Hi Ernesto,

    thanks for your reply.

    I typed this yesterday evening an re-read it now. For a further explanation: the users are registered with ulitmatemember which isn’t the problem because ultimatemember creates a regular wordpress user and puts some user meta on top.

    Some of the custom user meta we added were trainee positions like “computer sciences” or “global health care management” and so on. In total there are around 560 trainee options. For each user we store an individual selection of these 560 trainee positions in the user meta as serialzed data. Each user also has a company name and the companies address (not serialized) stored as user meta fields.

    Now if we search for (lets stick to the example) “global health care management” we get all the companies who offer this trainee track. If we use an additional dropdown filter for the cities (which is generated from all the user meta) and enter the search term “global health care management” everything is allright. We get all the companies in the city with this option.

    But if we enter “global health care management” AND the same city name in the search input field (without the filter) we get nothing as a result.

    I tried to use OR in combination with the two search terms but this gives me either alls results for the city regardless of the trainee position, or all the trainee positions regardless of the city.

    Would it be a big problem to change this in the code? I’m not afraid of performance problems because it’s a limited amount of users (regional event) and a limited amount of trainee positions. Maybe with an optional “mayham” checkbox? 🙂

    Thanks,
    Kai

    #20349
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi Kai,

    I have a feeling this should work, since there is no limitation for regular user fields, only buddypress xprofile fields. Can you make sure, that these fields are selected for search on the user search panel here?

    #20351
    lrrmlrrm
    Participant

    hi Ernest, (sorry for mispelling your name first time)

    yes, I was convinced that it should work but you can check it yourself.

    I’ve attached a file with all the user search settings. “firma_ort” is german and means “company_city”. It’s included.

    What do we do now?

    Thanks,
    Kai

    #20354
    Ernest MarcinkoErnest Marcinko
    Keymaster

    That looks okay to me.

    Well, the only possibility left is to debug the query directly. Can you please add temporary FTP access to the site? I will check on the generated query to see what the problem is.

    Also, can you share a test search phrase I should try, and which result should come up? That will make it much easier for me.

    #20355
    lrrmlrrm
    Participant

    You cannot access this content.

    #20395
    lrrmlrrm
    Participant

    Any news 🙂

    #20396
    Ernest MarcinkoErnest Marcinko
    Keymaster

    I am working on it at this moment. I might need to setup a test environment, as for some reason everything seems to be okay, yet the query is not returning correctly.

    #20397
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    I have managed to find a solution, but I am not sure how this will affect the performance, as it requires sub-query usage. I had to make a direct change in one of the search files.

    The change I made was in file wp-content\plugins\ajax-search-pro\includes\classes\search\class-asp-search-users.php on line 207 from this:

    $parts[] = "( $wpdb->usermeta.meta_key = '" . $meta_field . "' AND ( " . $pre_field . $wpdb->usermeta . ".meta_value" . $suf_field . " LIKE $pre_like'$wcl" . $word . "$wcr'$suf_like ) )";

    to this:

    $parts[] = "EXISTS( SELECT 1 FROM $wpdb->usermeta sums WHERE sums.user_id = $wpdb->users.ID AND sums.meta_key = '" . $meta_field . "' AND ( " . $pre_field . "sums.meta_value" . $suf_field . " LIKE $pre_like'$wcl" . $word . "$wcr'$suf_like ) )";

    Please make a copy of this, as unfortunately I cannot include this in an upcoming release due to possible performance consequences.

    #20398
    lrrmlrrm
    Participant

    I am working on it at this moment. I might need to setup a test environment, as for some reason everything seems to be okay, yet the query is not returning correctly.

    These are the best behaviours. 😀 😀 😀

    Ok, then I will make a backup and reinstantiate this when it when an update was made. I understand that you can’t include it by default but would it be possible to have a checkbox to enable it? Probably the problem occurs somewhere else and so there would be a solution before someone asks.

    Thank you very much!

    #20399
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    I thought of possible solution. I have added an additional query argument, that can be changed via a custom hook within the function.php file. So I changed the files, and I will include this change in the upcoming release as well, so you don’t have to overwrite it every time.

    Just keep this custom code in your theme functions.php file, and it will work without any changes:

    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;
    }
    #20400
    lrrmlrrm
    Participant

    You are the HERO of the day! Thank you very very much! 🙂

    #20401
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

    #20402
    lrrmlrrm
    Participant

    Yes, mark it as resolved. I will rate it very positivly 🙂

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘User Search and Multiple Keywords’ is closed to new replies.