Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Disable Searching 'Ending with' for Index Table
This topic contains 13 replies, has 2 voices, and was last updated by samyagshah 4 years, 6 months ago.
- AuthorPosts
- November 5, 2018 at 12:26 pm #19759
Is there any way to disable searching ‘Ending with’ for Index Table?
For example :
– “kar” will match “karate”
– “rate” shouldn’t match “karate”November 5, 2018 at 12:45 pm #19762Hi,
Maybe, by editing the database table structure. You could try changing the ‘term_reverse’ row in the database from varchar(50) to boolean. That would basically make the field usable, but the information stored would be neglected.
(before making any changes, I highly recommend having a full site + db backup!)
If you have a GUI databse editor like PHPMyAdmin, then it should be easyer. The table you should look for is wp_asp_index. Then you could edit the term_reverse field, and change it to boolean.I have not tested this, it is just a theory, but there is a slight chance, that it may as well work.
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 5, 2018 at 4:04 pm #19779Thanks its working. But one new problem.
When searched for particular Taxonomy, products associated to it is displayed, but actual taxonomy with product count in bracket is not displayed.
Say product category taxonomy named ‘Product-Category-1’ has 2 different products ‘Product-1’ & ‘Product-2’. When searched for ‘Product-Category-1’, ‘Product-1’ & ‘Product-2’ are displayed but actual ‘Product-Category-1’ with Product count is not displayed.
November 5, 2018 at 5:09 pm #19788Hi,
Make sure that the under the General Options -> Sources 2 the taxonomy in which the category belongs to is selected for returning as results: https://i.imgur.com/WmydGjP.png
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 6, 2018 at 5:51 am #19793Under Sources 2, if taxonomies in which the category belongs to is selected, all 3 types of search logic viz. Starting with, ending with & anywhere is used only for Sources 2 but I want only “starting with” to be used.
I am assuming you must be using operator like %keyword%. Can I update this logic to keyword%
I tried changing General Options -> Logic & Behaviour -> Secondary logic -> AND but it didn’t work.
November 6, 2018 at 8:18 am #19794I made following changes in /includes/classes/search/class-asp-search-terms.php :
1. Changed default value of $wcl variable to empty string.
$wcl = ''; // Wildcard Left
2. Added another where clause to retrieve values where the word is not the first in the title string.
/*----------------------- Title query ---------------------------*/ if ($kw_logic == 'or' || $kw_logic == 'and' || $is_exact ) { $parts[] = " (" . $pre_field . $wpdb->terms . ".name" . $suf_field . " LIKE $pre_like'$wcl" . $word . "$wcr'$suf_like OR " . $pre_field . $wpdb->terms . ".name" . $suf_field . " LIKE $pre_like'$wcr " . $word . "$wcr'$suf_like )";
And its giving desire output, but its affecting the performance. Could you please review it.
One quick question, since all required Taxonomies are indexed in index table can’t we disable source2 & add logic returning taxonomy terms as results in results returned by index table query?
-
This reply was modified 4 years, 7 months ago by
samyagshah.
-
This reply was modified 4 years, 7 months ago by
samyagshah.
-
This reply was modified 4 years, 7 months ago by
samyagshah.
November 6, 2018 at 12:37 pm #19803Hi,
That query is redundant in my opinion, because the first part (before the OR) is included within the second part. Wildcard searches using the ‘%’ symbol, mean, that there is either anything before the phrase or nothing. Basically ‘%phrase%’ includes the matches from ‘phrase%’ as well.
Best,
The performance degradation is because of the ‘%phrase%’ double wildcard query, as that cannot be performed as an indexed query by the database engine. Only the starting with queries (aka ‘phrase%’) can be performed as indexed (huge performance difference).
So changing the $wcl to an empty string, and not adding any additional code will give you the fastest possible results in this case.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 6, 2018 at 12:52 pm #19807I have added 2nd query in order to retrieve values where the word is not the first in the string. Say for Example:
Taxonomy Title is: “Ajax Search Pro – Very Powerful Search Plugin.”
Search Keyword is: “Search”No results are retrieved since Search Keyword is not first in the string. (In case of Source 2)
Logic used in 2nd query is : % search-keyword%
There is space between % & search-keywordAre we on the same page?
November 6, 2018 at 1:02 pm #19809I understand that. I am saying, that not changing $wcl should give the exact same results as changing + adding the query, as it is basically the same query but in a more complicated way.
Best,
– Because without the change, one like query match is executed for ‘%phrase%’.
– Whith the change, you have 2 like queries for ‘phrase%’ and ‘%phrase%’, where the ‘%phrase%’ actually includes everything matching the ‘phrase%’ as well.
I am not sure if I explained correctly, sorry about that.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 6, 2018 at 1:39 pm #19811Please find my comments below:
For #1: Because without the change, one like query match is executed for ‘%phrase%’.
Comment: Yes you are right.
For #2: Whith the change, you have 2 like queries for ‘phrase%’ and ‘%phrase%’, where the ‘%phrase%’ actually includes everything matching the ‘phrase%’ as well.
Comment: For 2nd like query there is space between % & phrase.
‘<% phrase%>’You are the expert, you can only tell me what needs to be done in order to achieve desired result.
November 6, 2018 at 2:05 pm #19812Oh, my bad, I didn’t notice that. That is very different then, sorry about that.
Best,
In that case, that is perfectly correct, I don’t think it can be further optimized unfortunately.
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 6, 2018 at 2:18 pm #19814No need to say sorry. 🙂
Two quick questions:
1. Since all required Taxonomies are indexed in index table can’t we disable source2 & add logic, returning taxonomy terms as results in results returned by index table query?
2. If #1 is not possible, is there any other way of adding above discussed like statements without modifying core files?November 7, 2018 at 10:43 am #19825Hi!
1. Unfortunately not, because the index table only contains the ID and the keyword from the taxonomy column. The taxonomy ID and the and term ID are not stored in there.
2. Actually, I think there is. You can add additional WHERE clause using this filter:
$add_where = apply_filters('asp_term_query_add_where', '', $args, $this->s, $this->_s);
Basically a code like this:
Best,
Ernest Marcinko
If you like my products, don't forget to rate them on codecanyon :)
November 16, 2018 at 7:33 am #19961Ok Thanks. Let me try.
-
This reply was modified 4 years, 7 months ago by
- AuthorPosts
You must be logged in to reply to this topic.