How to avoid partial word matches in search results?
Using Low Search 4.0 with EE 2.8.1
My problem is that partial word matches are returned as search results.
For example, if I search for tree, the top result is main street, which does not contain the word tree, but because the word tree is within the word street.
Or if I search for ann, results like alannah are included.
My results tag is:
{exp:low_search:results query="{segment_5}" collection="articles|issues" limit="20" orderby="low_search_collection:articles,issues"}
My understanding from the docs is that partial matching not the default. I've tried setting parameters keywords:loose="no" and keywords:mode="exact" but this makes no difference.
In another part of the website, I've a search section for a different collection, and the same thing happens there. So I would really appreciate some help to stop these partial word matches appearing.
Thanks for your time.
Replies
Low 5 Mar 2015 13:01
Can you post your full Form tag? You can use http://pastie.org/ or http://pastebin.com/ for large chunks of code.
Also, turn on template debugging and copy/paste all lines that mention low_search or Low Search here, please.
Tidy 5 Mar 2015 13:31
Thanks for the quick reply.
Here's the code from the search form template:
http://pastebin.com/Byq8ThZY
Here's the code from the search results template:
http://pastebin.com/deCaRRKq
Here's the main Low Search debugging output I can see in the search form template:
-------------------------------
(0.043158 / 13.54MB) Tag: {exp:low_search:form result_page="education/writers-directory/listings" form_class="form-horizontal"}
(0.043244 / 13.55MB) Closing Tag Found
(0.043310 / 13.55MB) Processing Tags
(0.043341 / 13.55MB) Module Tag: Low_search/form
(0.043355 / 13.55MB) Including Files for Plugins and Modules
(0.046877 / 14.00MB) Files for Plugins and Modules All Included
(0.049106 / 14.02MB) Beginning Final Tag Data Processing
(0.049132 / 14.02MB) Calling Class/Method: Low_search/form
(0.049796 / 14.03MB) -> Class Called: Low_search
(0.054990 / 14.76MB) -> Method Called: form
(0.058492 / 15.02MB) -> Data Returned
(0.235167 / 19.43MB) Calling Extension Class/Method: Low_search_ext/channel_entries_query_result
(0.281254 / 21.96MB) Calling Extension Class/Method: Low_search_ext/custom_field_modify_data
[this line repeated several times]
----------------------------------
Here's the Low Search debugging output in the search results template:
-----------------------------------
(0.038971 / 13.64MB) Module Tag: Low_search/results
(0.038984 / 13.64MB) Including Files for Plugins and Modules
(0.042256 / 14.10MB) Files for Plugins and Modules All Included
(0.042887 / 14.11MB) Beginning Final Tag Data Processing
(0.042908 / 14.11MB) Calling Class/Method: Low_search/results
(0.043547 / 14.12MB) -> Class Called: Low_search
(0.053775 / 14.85MB) -> Method Called: results
(0.070753 / 15.72MB) Low Search: Applying Low_search_filter_field_search
(0.089762 / 15.74MB) Low Search: Applying Low_search_filter_keywords
(0.089926 / 15.74MB) Low Search: No keyword search
(0.090721 / 15.74MB) Low Search: Setting entry_id param
(0.090961 / 15.74MB) Low Search: Parameters set: query="" collection="wis" limit="20" orderby="low_search_score|writer_surname|writer_name" sort="asc|asc" disable="member_data|category_fields" channel="wis" entry_id="7928|7934|7937|7956|8045|8049|8052|8067|8070|8081|8083|8086|8118"
(0.090973 / 15.74MB) Low Search: Pre-applying search vars to tagdata
(0.091524 / 15.75MB) Low Search: Calling the channel module
(0.162882 / 20.29MB) Calling Extension Class/Method: Low_search_ext/channel_entries_query_result
(0.191858 / 22.57MB) Calling Extension Class/Method: Low_search_ext/custom_field_modify_data
(0.201659 / 22.94MB) Calling Extension Class/Method: Low_search_ext/custom_field_modify_data
(0.281004 / 22.94MB) Calling Extension Class/Method: Low_search_ext/channel_entries_query_result
[this line repeated several times]
--------------------------------------
Low 5 Mar 2015 13:39
If you look at line 5 of your form, you'll see this:
This is actually using the Field Search filter, not the Keywords filter.
The name="search:title" input field, which translates to search:title="tree" for example, works identically to EE's native search:field="" parameters, which look for substrings.
You're better off using the Keywords filter, so change name="search:title" to name="keywords", which will trigger it.
Make sure your collections have searchable fields with a weight greater than 0.
Tidy 5 Mar 2015 14:27
Many thanks! Sorry, I didn't realise that the EE native search did this, and thought that Low Search on fields was just like keyword filter searches limited to one field.
I hadn't pasted the more complex search part of the site, which actually has both a title search field & a general keywords filter search field. Here's the form: http://pastebin.com/ax288wR0
So, is it possible to have separate search inputs for both a) just title and b) general keyword search of all relevant fields, while avoiding partial matches for both?
That is, can you have multiple keyword search fields limited to different collections (the search title field would be a keywords filter for a subset collection that just has the title field weighted > 0)?
Low 5 Mar 2015 14:34
You can't have multiple keywords fields targeting different collections, no.
But if you keep the search:title field, you can use contains_words="search:title" to disable words-within-words searching for that field, see http://gotolow.com/addons/low-search/...
Tidy 5 Mar 2015 14:41
Great that should do the trick - don't know how I missed that in the docs sorry.
Many thanks for all your time.