Not all results showing when searching custom field value

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Not all results showing when searching custom field value

This topic contains 12 replies, has 2 voices, and was last updated by

 
Participant
2 years, 3 months ago.

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #24407

    Participant

    Hi Ernest,
    On a real estate site I am developing I use drop downs based on custom fields. Im using {get_values}. Mostly it works well but on one search item, ‘property type’ the values are letters, a for appartment, m for house, etc. When i search in the drop down for c for commercial, only one result shows up, although there are at least 6 records/posts corresponding to ‘c’. If I use a custom query to search, all the 6 records(posts) show up in the results. Here is part of the php query:
    $querystr = ”
    SELECT $wpdb->posts.*
    FROM $wpdb->posts, $wpdb->postmeta
    WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
    AND $wpdb->postmeta.meta_key = ‘property_type’
    AND $wpdb->postmeta.meta_value = ‘C’

    AND $wpdb->posts.post_status = ‘publish’
    AND $wpdb->posts.post_type = ‘post’
    AND $wpdb->posts.post_date < NOW()
    ORDER BY RAND()
    LIMIT 20
    “;
    $pageposts = $wpdb->get_results($querystr, OBJECT);
    ?>
    This works perfectly (I use PHP code snippets in the page to get the result)

    But when I search ‘c’ in the drop down using Ajax search pro I just get one result. Like here:
    http://3dimmopro.ch/2017/searcher/

    Search property type is the only filter (all others set to ‘any’). There are 6 posts with ‘c’ as the property type but only one shows up in the results. I’m not using ACF and I know the records are there because I’m using a custom query in another area of the site.

    How can I get ALL the 6 results to show up in a search? Is there something I’m missing? I’ve been right through the documentation and searched on google but can’t find the solution.

    I hope I have explained myself clearly!

    Otherwise excellent plugin and just what my client requires.

    Many thanks

    Matt

    #24412

    Hi Matt,

    I think I know why. By default, the minimum word length is set to 2, which means, that single character queries are executed a bit differently. Please try changing this option to either 0 or 1: https://i.imgur.com/o3VMBFK.png
    That should very likely do the trick.

    Best,
    Ernest Marcinko

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


    #24413

    Participant

    Hi ernest,
    Thanks again for your quick reply!
    When I change it to 0 or 1 it brings up 200 results!
    It should only bring up 6
    Anythihg else I should change?
    cheers
    matt

    #24414

    Hi Matt,

    Can you please add temporary FTP and back-end details? I would like to check the exact configuration, and how the query is executed there. Thank you!

    Best,
    Ernest Marcinko

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


    #24415

    Participant
    You cannot access this content.
    #24416

    Participant

    Demo search page is here:
    http://3dimmopro.ch/2017/searcher/

    #24420

    Thank you!

    I have found the issue. It is the no_of_rooms (Pieces) filter. On the missing results this is set to 0, while the fitler range is 1-30. If you change the range to 0-30, or change the value of that field, then it should be fixed.

    Best,
    Ernest Marcinko

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


    #24423

    Participant

    Hi Ernest,
    Thanks for looking at this so quickly.
    I have changed the ‘number of rooms’ range to 0-30 but it still brings up 200 results.
    The search page is http://3dimmopro.ch/2017/searcher/ and the ‘property type’ dropdown is at the bottom of the search box.
    Any other ideas?
    Many thanks
    Matt

    #24424

    Hi Matt,

    Have you added the “Commercial” option with the value “C” to the filter? I don’t see it there yet: https://i.imgur.com/iBttfJg.png

    Best,
    Ernest Marcinko

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


    #24425

    Participant

    Hi Ernest,
    Yes, I’m using {get_values}
    It’s here http://3dimmopro.ch/2017/searcher/
    on the bottom row: ‘Property Type’
    cheers
    Matt

    #24426

    Participant

    The page is hidden, ie Its not on the front page of the site, I want to hardcode the search results as links in the top menu so I’m just using it to get the URLs. That way I can make a menu item ‘Commercial’

    #24427

    Oh, so you had two filters for the property_type, that is what confused me. The issue was, that the filter type was set to “equals” which is a numeric operator, while it should have been “exactly like”: https://i.imgur.com/zeRJZI1.png
    I changed it, and now it seems to be okay. I would not recommend however using two different drop-down filters for the same field (Property Type and the Type de Bien)

    Best,
    Ernest Marcinko

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


    #24428

    Participant

    Wow thanks Ernest! That seems to have done it! Brilliant!
    No, usually I wouldn’t use two different drop-downs for the same field, this is just my test page.
    Many thanks for all your help
    Matt

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

You must be logged in to reply to this topic.