Changing priority of content types for results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Changing priority of content types for results

This topic contains 1 reply, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 10 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #993

    I am working on setting this up on a dev server for a vacation rental property site. The owner is happy with the search, however, she wants the results of the properties to be higher then, for example, a page. The properties are custom content and I have them included and have told it to not search posts and it seems to help. However, if I type in the word Akumal I get the page for the webcam before I get the property results. Is it possible to change what has priority by page / post type, etc? Also, this dev server is not terribly fast, but it takes quite some time to bring up results with caching on. She is concerned it will be the same on the live site ( Not sure if it will or not, the live site in on AWS and load balanced.

    Thanks for any ideas / help. Great plugin!


    Ernest Marcinko
    Ernest Marcinko


    I’m currently working on a solution to make a search faster as ever, it might take a couple of days to finalize, but the initial results are promosing.

    In the meantime, the best way to get the search faster is reducing the results count (on the general options tab, “Max results”) from 30 to around 10. I forgot to change it when releasing the new version. 30 is a little bit too much. The caching is only active for phrases, that have already been searched. The most common reason of the slow search is however the images. All of the images are created on the fly, and that prodecure is a bit slow until the images aren’t searched at least once.
    By reducing the result count to 10 lowers the amount of images processed on the fly, it should speed up the search almost 2-3 times.
    The ‘Max result’ setting is going to be lowered to 10 results in the next verions 🙂

    As for your request, I think it might be possible, but you will need to edit one file for this.
    Open up the plugins/ajax-search-pro/includes/search_content.class.php file and go to like 195, you should see this:

    $querystr .= " ORDER BY relevance DESC, ".$wpdb->posts.".".$orderby."

    This code is responsible for the final ordering of the search results. Because you want to order by post_type first, you must change the line to this:

    $querystr .= " ORDER BY $wpdb->posts.post_type DESC, relevance DESC, ".$wpdb->posts.".".$orderby."

    or this:

    $querystr .= " ORDER BY $wpdb->posts.post_type ASC, relevance DESC, ".$wpdb->posts.".".$orderby."

    depending on your post type name. One of the solutions should work 🙂

    Let me know how it goes!

    Ernest Marcinko

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

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

You must be logged in to reply to this topic.