Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Maximum keyword length, and trigger normal search on settings change
This topic contains 4 replies, has 2 voices, and was last updated by Ernest Marcinko 5 years, 11 months ago.
- AuthorPosts
- October 27, 2017 at 2:11 pm #15314
Hello,
I tried the knowledgebase and forum search extensively but couldn’t find answers to these questions. Thanks for your time! 🙂
1. How can I adjust the maximum keyword length? For example, I’ve configured it to index a custom field which is a URL, however its clear that it only indexes the first ~30 characters.
Eg. custom field may contain URL “https://www.banggood.com/OnePlus-5-5_5-inch-6GB-RAM-64GB-ROM-Qualcomm-Snapdragon-835-Octa-Core-4G-Smartphone-p-1159492.html”
However search find nothing, yet it does find if only searching the first few characters: “https://www.banggood.com/OnePlus-5-5_5-inch-6GB-RA”
Which is not suitable, as my users need to paste a full URL.
2. Currently there is an option to trigger a LIVE search when modifying any of the settings. But triggering a non-Live search (showing results page) would be even more useful, for when users are selecting product categories dropdown. Is there an option for this, and if not, can you give me hint at what function to hook?
Congratulations on your very successful plugin.
-Simon
October 27, 2017 at 4:40 pm #15321Hi Simon,
Thank you very much for your kind words!
1. There is indeed a limit of 50 characters. Unfortunately this is a database table column limit, for maximum word length. The quickest solution would be to simply use the Regular engine instead of the Index table. If that is not suitable in your case, then I’m afraid the only possibility is to change the row type of the index table manually.
For that you will have to run a custom SQL query directly on the MySQL server via PHPMyAdmin or other tool. Before doing so, please make sure to have a full site back-up including the database! Running custom queries is dangerous and the tyniest mistake can result in data loss, so please be careful:
After the change re-creating the index should do the trick.
2. You mean LIVE re-freshing the results page whever the user changes an option? Such feature is under development, will be available soon.
..or do you mean doing a redirection (like when hittin the return button) whenever the user changes an option? Thish actually might be possible using the search javascript API. I have quickly made a custom script that is automatically added to the site footer. This javascript attaches to the change event of any option within any search instance, and triggers a ‘searchFor’ API call.
Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!
I’m not sure if this will work correctly, but it’s worth a try. I hope this helps.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
October 28, 2017 at 12:56 am #15326Incredible response, thank you!! I’ll be implementing these changes today.
October 28, 2017 at 4:06 am #15327#1 Increasing keyword length from 50 to 180 maximum
The above suggestion sort-of works, except I had to change VAR(255) to VAR(190) as 255 gave a too big (bytes?) error.Thing is, the full term isn’t found, but strangely it works if I remove everything after the ? in the URL.
Eg. Doesn’t work (actual term indexed): https://www.banggood.com/OnePlus-5-5_5-inch-6GB-RAM-64GB-ROM-Qualcomm-Snapdragon-835-Octa-Core-4G-Smartphone-p-1159492.html?p=FxxxxxxxxxxxxxxxxIV
#2 Doing a redirection (like when hitting the return button) whenever the user changes an option
The code ALMOST works. It does a search, but searches for nothing (/?s=). There must be something missing, i’ll try figure it out 🙂
-
This reply was modified 5 years, 11 months ago by
ozzymuppet. Reason: added detail
-
This reply was modified 5 years, 11 months ago by
ozzymuppet.
-
This reply was modified 5 years, 11 months ago by
ozzymuppet. Reason: clarified
Attachments:
You must be logged in to view attached files.October 30, 2017 at 7:21 am #15334Hi!
1. It is because the ‘?’ character in the URL is recognized as a possible word delimiter, and the URL is split there. Remember, that the index table engine is specialized to recognize as many words as possible. It cannot first detect URL specific schemes and treat them as separate words, I’m afraid that is not possible.
I believe that using the regulare engine might honestly be the best idea here. If you want the whole URLs to be indexed, there is almost no difference searching those meta fields, as searching the same exact field in the index table.
2. It will use the keyword that is typed in to the search box. Line 19 is the search phrase parameter, you can change that to any string you want to:
$('#ajaxsearchpro' + idArr[1] + '_' + idArr[2] + ' input.orig').val() // This gets the search input value
I hope this helps!
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
-
This reply was modified 5 years, 11 months ago by
- AuthorPosts
You must be logged in to reply to this topic.