All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

Low Search filtering is returning more results than it should due to a "like" search not working correctly??

Jason Boothman 14 Mar 2019 19:46 problem, complete

We have a website where you can filter Tires & Wheels by Wheel Size. There are many options.

Some examples are 15x6, 16x6, 16x6.5, 16x6.75, etc.

Note: Those are the values as they appear in the query string as well (this is being imported form a massive database where we don't have control over said values).

If a user selects 16x6.75 it works as expected and only returns those results. If you select 16x6, however, it is returning results for 16x6, 16x6.5 and 16x6.75. I assume that it is using an in search, which is why it is returning all those results - but is there any way to refine it more than that?

Replies

  1. Low 14 Mar 2019 19:52

    If you're using the Field Search filter for this, which you should, then the default matching is a 'contains' search. If you need the field to match exactly, use either the exact="" parameter (if the target field contains just one size) or else try the contains_words="" parameter (if the target field can contain multiple sizes, like a multi-select or checkboxes field).

    Low 14 Mar 2019 19:56

    (thinking the contains_words="" param won't cut it, as that will generate a REGEXP clause in MySQL which uses word delimiters, which . is, so the same issue would persist.)

  2. Jason Boothman 14 Mar 2019 19:56

    I have a basic results tag and I'm relaying on form variables and query strings to provide all the necessary filtering as there are quite a few categories and fields to be filtered by.

  3. Low 14 Mar 2019 19:58

    Then what's the opening Results tag and accompanying query string?

  4. Jason Boothman 14 Mar 2019 20:00

    This is what I'm using for the results tag.

    {exp:low_search:results collection="products" limit="12" paginate="bottom" disable="category_fields|member_data"}

    You can see how it works at http://ttw0518-01-18.71.reusser.desig...

  5. Low 14 Mar 2019 20:13

    See how this page, filtering by 16x6 size, also contains 16x6.5 sizes?

    http://ttw0518-01-18.71.reusser.desig...

    Now, if I add the exact="" parameter to the query string, those entries are not there:

    http://ttw0518-01-18.71.reusser.desig...

    The same goes for when I prepend the parameter value with a (URL-encoded) = (which has the same effect as using the exact="" param)

    http://ttw0518-01-18.71.reusser.desig...

    For now, I'd add this to your Results tag:

    exact="search:product_wheel_size"


    ...and add more parameter names to it, if other fields need to match exactly, too. For example:

    exact="search:product_wheel_size|search:product_bolt_pattern|search:product_tire_size"


    ...and so on.

  6. Jason Boothman 14 Mar 2019 20:17

    Awesome - I think that's exactly what we need. Thank you Low!