Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Bio search works till fourth or fifth keyword only
This topic contains 9 replies, has 2 voices, and was last updated by Ernest Marcinko 6 years, 10 months ago.
- AuthorPosts
- March 4, 2016 at 5:59 pm #7907
Hi there. I want ajax search pro to search users bio. Search goes fine till 4-5 keywords but after that any insignificant keyword mentioned still opens up same results. I am not using indexing. All i want to be searched is the contents in users bio. I want results to come up only if all words entered as keywords matches the contents in user’s bio. Even if there is a single word which does not match the content, i dont want results for it. Bio has about 1000 characters.
March 7, 2016 at 9:31 am #7916Hi!
For multiple keywords I suggest changing the keyword logic. By default it’s an “OR” type of logic used, which aims at matching any of the keywords that the user types in. In your case I believe a more strict logic would solve this problem.
Here on chapter 14 in the documentation you can read more about the search logic and how to change it. I suggest trying the AND logic first.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2016 at 10:28 am #7917Hi
I have done all the research on keyword logic. I am using And with exact match. Let me explain myself again. I want search to happen in user bio so that the results are shown only if all the words matches. Currently its matching up to 6 words. Any random 7th word or even 8th word mentioned is not matched. So if for example, a user bio has list of all the countries in Asia. I want that profile to show up only if all the countries name (keywords) mentioned are in Asia. If even one country is mentioned out of Asia, the result should not show up. This was just an example. Please help!
March 7, 2016 at 11:14 am #7918I thought you meant 4-5th keyword, not over 6th. 7 or more keywords are indeed ignored for performance and security reasons.
You can of course change that by making a small edit in the following file: wp-content/plugins/ajax-search-pro/includes/classes/search/search.class.php and lines 139-140, where you should see this:
$this->_s = $this->escape( array_slice(array_unique( explode(" ", $keyword) ), 0, 6) ); $this->_sr = $this->escape( array_slice(array_unique( array_reverse( explode(" ", $keyword_rev ) ) ), 0, 6) );
…change those to:
$this->_s = $this->escape( array_slice(array_unique( explode(" ", $keyword) ), 0, 25) ); $this->_sr = $this->escape( array_slice(array_unique( array_reverse( explode(" ", $keyword_rev ) ) ), 0, 25) );
This way it will allow 25 keywords instead of 6. If you experience any performance issues, then reduce this number to a lower one.
In case you can’t find these lines or having trouble with editing, feel free to update your FTP information and I will take care of it for you.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2016 at 11:16 am #7919I am using a 14 gb ram dedicated server. Do you suggest that performance will not hampered by increasing the limit from 6 to 25?
March 7, 2016 at 11:21 am #7920Unless you have hundreds of thousands or millions of users it should not be an issue. If you know the possible highest amount of keywords that the user will likely to enter, then use that number instead.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
March 7, 2016 at 11:23 am #7921one last thing. How to let the search algorithm ignore all the connectors like The,a,at,on etc ?
March 7, 2016 at 11:25 am #7922On the Advanced Options -> Keyword Exceptions panel with the “Keyword exceptions – replace whole words only” option. You can enter a comma separated list of words you want to have ignored.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
June 19, 2017 at 10:49 am #13651Hi earnest, Since i already paid when i created this topic and the issue is popping up because of the software change from your end, please reply and do not simply close this to make me pay again for asking the same question. I would hate to give a bad review!
I could no longer find wp-content/plugins/ajax-search-pro/includes/classes/search/search.class.php
So where do I go and change more than 6 or 7 keywords to be chosen.
June 19, 2017 at 3:40 pm #13667Hi,
The file has been re-named to:
wp-content/plugins/ajax-search-pro/includes/classes/search/class-asp-search.php
..and the lines have been changed slightly, they should be found on positions 118-119, they look like this:
$this->_s = ASP_Helpers::escape( array_slice(array_unique( explode(" ", $keyword) ), 0, 6) ); $this->_sr = ASP_Helpers::escape( array_slice(array_unique( array_reverse( explode(" ", $keyword_rev ) ) ), 0, 6) );
..just change them to this:
$this->_s = ASP_Helpers::escape( array_slice(array_unique( explode(" ", $keyword) ), 0, 25) ); $this->_sr = ASP_Helpers::escape( array_slice(array_unique( array_reverse( explode(" ", $keyword_rev ) ) ), 0, 25) );
PS: Update for the upcoming release
I will make sure to add an additional argument to the search params, so this number will be changeable without direct modifications, only by using a filter code, in the upcoming release.
For that, you will only need this code, placed in the functions.php file in your theme/child theme directory (copy from line 3):This will work after the next update is released.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
- AuthorPosts
The topic ‘Bio search works till fourth or fifth keyword only’ is closed to new replies.