Forum Replies Created
-
AuthorPosts
-
Ernest Marcinko
KeymasterHi!
Multisite only affects that if you are searching multiple blogs.
I’m just finishing a newer version, so far I got around 150% speedup (from an initial 2s to around 700ms). I figured out, that the main reason for the slow responsen is mainly the fact, that for each ajax request the whole WordPress core is loaded, which is usually slow as hell. I’ve found a nice tweak to minimize the resources needed to make this functional, however it needs a bit more testing.I’m sending you a copy of this, you should experience huge speedups.
After extracting the zip file, please upload it to your server, overwriting the old search files, then open up the search you are using and save it, just so the new options get to the database. BACKUP THE OLD SEARCH FIRST!
Then open up the caching options tab, make sure, that the TimThumb option is enabled and save it.
Then do some testing, it should work much better, at least I hope so. If something goes wrong, use the backup 🙂
Ernest Marcinko
KeymasterHi!
Good news! I have located the issue, it was something wrong with the content filtering, not sure what. Either way, I tracked down and removed 1 line from the search, it should work now perfectly!
Best,
ErnestErnest Marcinko
KeymasterHi!
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
KeymasterHi!
It’s usually the images in the search results. Each image must be parsed once, and the resizing may take a while if the initial image is large.
What I usually recommend is to limit the search results down to 10 from 30 (on the general settings panel the “Max. results” option)
It should speed up the search by a few seconds.You can also turn off the images temporary, to see how faster is the search without them. If it’s much faster, then definitely the images are the problem.
Let me know how it goes!
Ernest Marcinko
KeymasterHi!
Still cant login to ftp. I have tried the username enterta0 with the given url and also with the web url, but no luck 🙁
Can you please check it again?
Ernest Marcinko
KeymasterI was just going to sleep when I got your message. I’m located in central Europe 🙂 I’ve updated the sidebar of this site to see the support schedule, so customers from US and Australia won’t get frustrated.
Anyways, I’m going to look at this in a minute. Will let you know if I find the problem 🙂
Thanks!
Ernest Marcinko
KeymasterGot your mail, thanks! I removed your site info from the first post as well.
Ernest Marcinko
KeymasterOk, I have moved this thread from spam to normal, sorry about that, the Akismet anti-spam sometimes doesn’t work as I want it 🙂
Somehow the admin/ftp details weren’t saved (I guess it was because of the spam issue). Can you please edit the first post and fill out the details again? If it’s not going to work, then my email address is ernest.marcinko[at]wp-dreams.com, you can send it there.
Until then I will set up my hosts file. I can’t promise you anything, but I will try to make it happen 🙂
Ernest Marcinko
KeymasterHi!
Thank you! I would rather recommend using PHP to achieve such thing insted of javascript. The good thing with v2.0 is that I have implemented a bunch of filters and actions, that we can use to make our lives easier 🙂
However there is no filter for changing the url, there is still a way around it. The filter called “asp_results” passes all the results as an array of objects to a desired function. This means, that we can scrape the url out of it and change it as we like:
add_filter('asp_results', 'my_changeBaseUrl',10,1); function my_changeBaseUrl($results) { foreach ($results as $k=>$result) { $results[$k]->link = str_replace("replace this", "with this", $result->link); } return $results; }You can put this code to you templates functions.php file, or into the bottom of the plugins/ajax-search-pro/search.php file. If you replace the “replace this” and the “whith this” string in this code with the desired string, it should work 🙂
Ernest Marcinko
KeymasterYou can turn off the search in posts, search in pages options on the backend, on the general options tab. But if you dont need those options it’s faster to add the following lines after the code I provided earlier:
print_r(json_encode($_termres)); die();This will make the search ignore everything after printing the category results – will make it somewhat faster.
You probably want to get rid of the settings box as well, it’s not needed for this kind of search. The best was to do this is by turning off everything on the “FRONTEND SEARCH SETTINGS” panel and after saving the options, the settings box will disappear from the frontend.Ernest Marcinko
KeymasterGood news. If you want to show the taxonomy terms in the result I have a working solution. You will need to open up the plugins/ajax-search-pro/search.php file and go to line 141, where you should see this:
$params = array('data'=>$search['data'], 'options'=>$search['options']);After this line, instert the following code:
/* Extra for searching custom taxonomies */ function _getAllTaxonomies() { $args = array( 'public' => true, '_builtin' => false ); $output = 'names'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies = get_taxonomies( $args, $output, $operator ); return $taxonomies; } function _getLikeTerms($name) { $taxonomies = _getAllTaxonomies(); $terms = array(); foreach ($taxonomies as $taxonomy) { $terms[$taxonomy] = get_terms($taxonomy, array( 'orderby' => 'name', 'name__like' => $name )); } return $terms; } $_like_terms = _getLikeTerms($s); $_termres = array(); foreach ($_like_terms as $taxonomy=>$terms) { foreach ($terms as $term) { //var_dump($term); $_termo = new stdClass(); $_termo->id = $term->term_id; $_termo->content = ""; $_termo->title = $term->name; $_termo->date = ""; $_termo->author = ""; $_termo->image = ""; $_termo->link = get_term_link( $term, $term->taxonomy ); $_termres[] = $_termo; } } $allpageposts = array_merge($allpageposts, $_termres); /* END Extra for searching custom taxonomies */And that’s it. Not sure how efficient this is, but this should work 🙂
Ernest Marcinko
KeymasterOk, I need more information on this.
Let’s say you have a custom taxonomy called product-categories, which has the following terms: “Clothes”, “Food”, “Vegetables” …
Do you need the “product-categories” as the result, or the terms “Clothes”, “Food” … ?
Ernest Marcinko
KeymasterHi!
Not possible in the current plugin state. I’m looking for a solution if there is an easy way to achieve this by modifications. Actually returning taxonomies as search results is maybe an extra 100 lines of code or less. The problem is to fabricate the url, where these results would lead the user. Apparently the url structure is something like yoursite.com/index.php?taxonomy_name=the-taxonomy-name but I can’t confirm this works 100%.
Let me check if I can make a modification to return custom taxonomies on my test server 🙂
Ernest Marcinko
KeymasterHi!
I almost got this. It was something wrong with the multisite options, I reverted it to default and it shows results now. However if I select the agent and the property custom post type, it does not search them. Couldn’t figure out why yet. Can you please check the ftp access you gave, I cannot log in through my ftp client with it. I might need to run a few debugging test to figure out why it isn’t searching the properties 🙂
Thanks!
Best,
ErnestErnest Marcinko
KeymasterHi Mike!
Will look at this first thing tomorrow morning as soon as I get into the office (~9 hours). Thank you for the detailed description and login details. It will make this a lot easier to solve 🙂
Probably it’s just a minor issue, no worries.
Best,
Ernest -
AuthorPosts