No Results Being Returned For Custom Field Only Search

Home Forums Product Support Forums Ajax Search Pro for WordPress Support No Results Being Returned For Custom Field Only Search

This topic contains 11 replies, has 2 voices, and was last updated by jesseslam jesseslam 9 years, 4 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #3011
    jesseslam
    jesseslam
    Participant

    Hi,

    I have just purchased and installed your plugin into my client’s multisite but I’m having a problem returning any results as we only want the plugin to search a custom field we have created called search_terms and nothing else and to search all sub sites, this is so we can specify exactly which page or result is returned for each search. My client only wants as few results as possible to come back so the user isn’t overwhelmed with choice.

    For the time being I have added our old search box back into the header but I have added your search box to the bottom of the sidebar on this page http://www.duracomposites.com/dura-grating-fibreglass-grating/ so you can test it ans see it in action.

    If you do a search for ‘grid flooring’ only one page should be returned which is the page you are on http://www.duracomposites.com/dura-grating-fibreglass-grating/ but as you can see there are no results. Would you mind having a look at the settings to see why this sin’t working as we want it?

    Many thanks,

    James Isles

    #3012
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    I ran throuhg some tests on the site. There were no results because the “Search in pages” option was disabled, thus there was nothing for the plugin to return.

    I enabled this option, now it returns exactly the page you linked for the “grid flooring” search term.

    Best,
    Ernest Marcinko

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


    #3019
    jesseslam
    jesseslam
    Participant

    Hi Ernest,

    Thanks for that I’m sure I tried that and it ended up searching all the content. That now works although some of the images are not working. if you do a search for ‘composite decking’ at the bottom on this page http://www.duracomposites.com/dura-grating-fibreglass-grating/ again you will see what I mean, how can we get them working please>

    Thanks,

    James Isles

    #3022
    jesseslam
    jesseslam
    Participant

    Hi Ernest,

    An update in this I have been playing around and it seems that it’s images from other sites in the multisite that the images don’t show and are broken is there a way to fix this?

    Thanks,

    James Isles

    #3023
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Thanks for the information. Somehow the image handling library reported that the image does not exists, while it was there, so I inserted a bypass code to use the internal image handler, now it should work fine 😉

    Best,
    Ernest Marcinko

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


    #3024
    jesseslam
    jesseslam
    Participant

    Hi Ernest,

    That’s great thank you yes it all works now. Where did you ad the code will this be overwritten by plugin updates?

    Thanks,

    James

    #3025
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    No problem at all.

    The tiny change is in wp-content/plugins/ajax-search-pro/includes/search_content.class.php on line 346. The old code was:

    
    if ($use_timthumb == 0) {
    

    and I replaced it with the bypass:

    
    if (1) {
    

    This will be overwritten by updates, however all you need to do is change this one line. The line number will probably change, but if you search for “if ($use_timthumb == 0) {“ in the file, you will find it, it only occures once.

    If you can’t change it or something goes wrong, you can reply to this thread and I will do it for you.

    Best,
    Ernest Marcinko

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


    #3026
    jesseslam
    jesseslam
    Participant

    Thanks Ernest. Is there no way to disable timthumb in the settings as your documentation shows this is possible but I couldn’t find it anywhere?

    #3028
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    It’s possible (on the “Cache settings” submenu), but on multisite setups that setting is ignored for various reasons. In your case I needed to make an exception and disable it programatically, because of the unexpected timthumb output.

    Best,
    Ernest Marcinko

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


    #3043
    jesseslam
    jesseslam
    Participant

    Hi Ernest,

    Thanks for your previous help but the search isn’t work how my client would like if I tell you how we want it to work then maybe you can let me know the way it needs to be set up?

    My clients ways the search function to only search the custom fields search_terms as you already know. This is so we can make the search very strict and only add the terms we want to the relevant pages meaning ultimately the user only has one or two search results to choose from. All the keywords have been added into the relevant pages into the search_terms field but it doesn’t seem to be working. If you search for ‘fibreglass grating’ the only page we want to be returned is this page http://www.duracomposites.com/dura-grating-fibreglass-grating/ as this is the only page we have the search phrase on but as you can see this page isn’t being returned. The returned results do have the term ‘fibreglass grating’ in the custom field but not on it’s own they are part of a longer tail term like ‘Fibreglass Grating Fixings’. Another example of this is ‘roof walkways’ the only page we would like to show in the results is this page http://www.duracomposites.com/roof-walkways/ but it doesn’t show at all.

    They would also like the search to work in a way that we can specify exact match single work search as well so if someone searched for ‘decking’ this only returns the pages we have added ‘decking’ into as a keywork and not ‘composite decking’ for eample is this also possible?

    If you need to know anything else let menow but if you can let me know the settings we need to get the search to work as we want that would be great.

    Many thanks,

    James

    #3044
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    I see now. So the keywords are stored in the search_terms custom field as “keyword 1, keyword 2, keyword x” – thus comma+space separated.

    I made a few modifications on the source code that should respect this rule, so only the whole keyword matches should be returned.
    I think it should work now as you described.

    I’m attaching the changed lines here for future reference to myself. file search_content.class.php line 167 custom_field search related:

    
    // NOTES: whole word, comma-space-WORD-comma, BOL-word-comma, comma-space-word-EOL
    $parts[] = "($wpdb->postmeta.meta_key='$cfield' AND 
                (
                     lower($wpdb->postmeta.meta_value) LIKE '".$s."'
                  OR lower($wpdb->postmeta.meta_value) LIKE '%, ".$s.",%'
                  OR lower($wpdb->postmeta.meta_value) LIKE '".$s.",%'
                  OR lower($wpdb->postmeta.meta_value) LIKE ', ".$s."'
                 )
                )";
    
    Best,
    Ernest Marcinko

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


    #3045
    jesseslam
    jesseslam
    Participant

    Hi Ernest,

    Thanks that’s really helpful and thanks for coming back to quickly. I have emailed my client so they can test.

    I will take a backup of your modified files.

    Thanks again.

    James

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

You must be logged in to reply to this topic.