Parameter keywords:loose="right" not doing what I think it should...
Hi, Low! So, I'm using Low Search 4.1.1 on EE 2.10.1. The site I'm working on has lots of different types of products, which can be configured in many many different ways, resulting in a huge number of unique identifiers / configurations. Check out the Build # section of the 'Build Your Own' section of this page: http://farnam-custom.com/standard-pro...
So, in my Products channel, I have an extra field that I can just plop any keywords that I want your awesome add-on to index for that product. But it would be crazy to dump in every single permutation of every possible product configuration in there. But I've gone ahead and made sure each product has its basic product code in there (like FT600, in this example)
Looking at our search logs, we find that many customers are trying to find products by entering in their unique build # in the search box, like 'FT600-8000-480-3-3T-3T-TF1'. But that search term won't bring up any results, even though I have 'FT600' in that field I mentioned, indexed by Low Search.
My {exp:low_search:results} tag looks like this:
{exp:low_search:results
query="{segment_2}"
collection="not monkeyfart"
status="open"
show_expired="no"
disable="member_data|category_fields|categories"
keywords:lang="en"
keywords:loose="right"
keywords:mode="any"
keywords:inflect="yes"
keywords:stem="yes"
}
So, I figured having mode = any, and loose = right should make it return my product that has "FT600" when the search term is "FT600-8000-480-3-3T-3T-TF1", but, alas, it doesnt.
Can you tell me what I'm doing wrong? Is it the dashes? Or, is there a better way to go about this?
Thanks!
Replies
Low 14 Nov 2015 07:45
The dashes shouldn't be an issue -- they get stripped out of both the search index and keywords.
First of all, I'd try and upgrade to the latest version (v4.4.0 at the moment).
Is the field where you enter the FT600 code weighted in the collection?
Can you enable template debugging and copy/paste all lines that mention Low Search/low_search here? That can provide insight as well.
Lastly, if you enable the output profiler, you can look up the query generated by Low Search (by the lsf.keywords.php file). What does that say?
Gary Reckard 17 Nov 2015 14:49
Hi again,
So here is the output from the template debugger when I use the keywords "FT600-8000-480-3-3T-3T-TF1"
http://pastebin.com/YKyV4FHf
I notice, on line 23 there, it shows the keywords without dashes...
In the output profiler, the relevant query was:
SELECT exp_low_search_indexes.entry_id, exp_low_search_indexes.collection_id, exp_low_search_indexes.index_text
FROM ('exp_low_search_indexes')
WHERE 'collection_id' IN ('1', '2', '3', '4', '5', '6', '7', '8')
AND 'exp_low_search_indexes'.'site_id' IN ('1')
AND 'index_text' LIKE '% ft600 8000 480 3 3t 3t tf1%'
Thanks for your help!
Low 17 Nov 2015 14:53
Yeah, it's meant to do that.
That leads me to think that the field where you store that data isn't present in the collection index.
Can you verify that?
Gary Reckard 17 Nov 2015 14:56
Sorry, yes, i meant to verify that in my last message. Here are my settings for that collection.
Low 17 Nov 2015 14:57
I'll need to take a look myself. Please send SuperAdmin login credentials to hi at gotolow dot com if you can.
Gary Reckard 17 Nov 2015 15:06
Done, thanks!
Low 17 Nov 2015 15:22
OK, I think I know what's the deal here.
Dashes (hyphens) in keywords are stripped out before search, but the words connected via hyphens are considered as a single term.
So, 'foo-bar' will search for 'foo bar'.
Searching for 'foo-bar' with keywords:loose="right" will look for 'foo bar*'.
This is why it won't find that entry: the term "FT600 8000 480 3 3T 3T TF1" is not found, and using keywords:loose="right" will look for 'FT600 8000 480 3 3T 3T TF1*'
There isn't a way around this behaviour out of the box. You could modify the keywords before submit (replacing hyphens with spaces) or create an extension that does this, using the low_search_pre_search hook.