I know this is risky to make such a statement, but I am really afraid something is wrong and I do not know how to solve it. I did rebuild the tables from the CP.

Module: LOW search, system: EE ExpressionEngine v2.9.2 - Build Date: 20141004, Stash is used to produce a unique list for the found terms.

We search in 2 categories and 1 (one) field: 'Materials'.

test URL http://www.kc-vast.se/index.php/tests/SokTest

The problem is in the returned "search-words" that sometimes do not match the actual search. Sometimes words are missing, but I can see them in the entrees (results)

This goes well (example): Searching for 'sten' gives good result. Filtering category 1 with 'sten' also.

This goes wrong (example): 'vatten' 'ljus' 'sociala media' 'video'.

Assistance really appreciated. Thank you for looking at this.

EDITED 2016/11/16 21,15 CET Code for the combined test searchform and result page here:

        <!-- PageContent -->
    {exp:stash:set parse_tags="yes" save="yes"}<!--  main stash tag -->
          {stash:page_content} <!-- get page content -->
          {stash:ThisPageTitle}test for searching material on Kc-väst{/stash:ThisPageTitle}<!--  get the page title here -->
<div class="row colorWhite clearfix">
    <div class="medium-12 columns">
        {exp:low_search:form
    result_page="tests/SokTest"
    }
    <fieldset class="fieldset">
        <legend>category 13</legend>
        <div class="small-up-2 medium-up-4 large-up-6">
      {exp:channel:categories category_group="13" style="linear"}
        <label class="column">
          <input type="checkbox" name="category[]" value="{category_id}"{if low_search_category ~ '/\b'.category_id.'\b/'} checked{/if}>
          {category_name}
        </label>
      {/exp:channel:categories}
  </div>
    </fieldset>
    <fieldset class="fieldset">
        <legend>category 11</legend>
        <div class="small-up-2 medium-up-4 large-up-6">
      {exp:channel:categories category_group="11" style="linear"}
        <div class="column">
        <label>
          <input type="checkbox" name="category[]" value="{category_id}"{if low_search_category ~ '/\b'.category_id.'\b/'} checked{/if}>
          {category_name}
        </label>
        </div>
      {/exp:channel:categories}
  </div>
    </fieldset>
    <fieldset class="fieldset">
  <legend>Materials</legend>
        <div class="small-up-2 medium-up-4 large-up-6" >
  {exp:low_options:material_content}
    {options}
        <div class="column">
            <input id="{option:label}" type="checkbox" name="search:material[]" value="{option:value}"
        {if low_search_search:material ~ '/(^|\|)'.option:value.'(\||$)/'} checked{/if}><label for="checkbox1">{option:label}</label>
        </div>
    {/options}
  {/exp:low_options:material_content}
  </div>
    <button class="tiny button float-right" type="submit">TestSearch</button>
    </fieldset>
  {/exp:low_search:form}
    </div>
    <div class="medium-8 columns">
<!--        use stash list to get non repeating search words -->
            {exp:stash:set_list name="found_materials"
            parse_tags="yes"
            parse_depth="2"
            }
                {exp:low_search:results
                  query="{segment_3}"
                  status="not closed"
                  disable="member_data|category_fields"
                  exact="search:material"
                }
                                            {stash:item_material}{material}{/stash:item_material}
                                            {stash:item_category}
                                                {exp:channel:categories show="{low_search_category}" style="linear"}
                                                <strong>{category_name}</strong><br>
                                                {/exp:channel:categories}
                                            {/stash:item_category}
                {/exp:low_search:results}
            {/exp:stash:set_list}
<!-- end set stash list -->
<h2>Results</h2>
<ol class="searchtestol">
    {exp:low_search:results
      query="{segment_3}"
      status="not closed"
      disable="member_data|category_fields"
      orderby="material"
      sort="asc"
    }
<!-- search result here -->
        <li>{title} by {konstnar}, with: <b>{material}  {exp:channel:categories show="{low_search_category}" style="linear"}<strong>({category_name})</strong><br>{/exp:channel:categories}</b></li>
    {if low_search_no_results}
        <p>
         Inget resultat
        </p>
      {/if}
    {/exp:low_search:results}
</ol>
    </div>
    <div class="medium-4 columns">
<h2>unique list of exact terms</h2>
<ol class="searchtestol">
    {exp:stash:get_list name="found_materials" unique="item_material"}
     <li>{item_material}</li>
    {/exp:stash:get_list}
    </ol>
<h2>Category:</h2>
    <ol class="searchtestol">
    {exp:stash:get_list name="found_materials" unique="item_category"}
     <li>{item_category}</li>
    {/exp:stash:get_list}
</ol>
    </div>
</div>
{/stash:page_content}
            {/exp:stash:set}
<!-- end PageContent -->
up vote 3 down vote accepted

First of all, don't worry. Your database is not corrupt, nor are you getting any database error messages. Most likely, your setup isn't producing the results you are expecting due to a combination of certain search parameters.

There's a lot to take in here, I'd recommend you clean up the template by getting rid of other tags and duplicates to make sure Low Search is returning the correct search results for you.

That said, I can point you to a couple of things that I noticed here.

First of all, all selected categories are combined with OR. In your current setup, all category checkboxes have a name="category[]", which means that Low Search will return entries that have any of the checked categories assigned to it. If you want to return entries that have all checked categories assigned to it, then use the require_all parameter, as explained here.

Note that if you want to limit that to categories belonging to the same group, so for example (Boendemiljö OR Förskolor) AND (konst i rum OR konst inne), then use the Category Groups option, to treat each category group as a separate parameter.

Second of all, as with the categories, all selected materials are combined with OR. Like the categories, the Field Search parameter you set up will return all entries that have any of the selected materials selected. This means searching for vatten, ljus, sociala projekt and video will return entries where that field contains one or more of these values. If you want to return entries where that field contains all of the checked values, then use the require_all parameter, as explained here.

Thirdly, I can see that you're using exact="search:material" in one of the Low Search results tags (I wouldn't recommend using multiple, by the way). Setting that parameter will only return entries where the field would exactly match the given parameter completely. With multiple values, that would mean a field would have to exactly match 'foo' AND 'bar', which is never the case. I'm not sure what you're after with that list, but I'm pretty sure you need to use something other than exact here.

There are other tweaks you can do, too, unrelated to the issues you're having:

  • sort="material" won't do anything. You're looking for orderby="material" sort="asc".
  • The shortcut="{segment_2}" seems odd. Are you sure you want to display shortcut results here?
  • The orderby parameter on the Low Options tag won't do anything.

Finally, what I find odd is that you're generating a list of materials using Low Options and the material_content field, yet you're targeting the material field. Usually, you would generate the options of a field to create a list of search values for the same field. Are you sure you meant to do this?

As I said, plenty of stuff to tweak. But rest assured, your database is in no way corrupt nor generating any errors.

Added later: how to output a list of given search terms and parameters

If you want to list all the options and categories that were selected, then you don't need to loop through all the search results to collect those values. You can already output the parameter values using the {low_search_param-name} syntax, and use that in the Form, Filters or Results tag. For example:

{exp:low_search:filters query="{segment_3}"} 
    <h2>unique list of exact terms</h2> 
    <ol class="searchtestol"> 
        {exp:low_list:each items="{low_search_search:material}" as="val"} 
            <li>{val}</li>
        {/exp:low_list:each} 
    </ol> 
    <h2>Category:</h2> 
    <ol class="searchtestol"> 
        {exp:channel:categories show="{low_search_category}"} 
            <li>{category_name}</li> 
        {/exp:channel:categories} 
    </ol> 
{/exp:low_search:filters} 

...which uses Low List to output a pipe-separated list.

  • Hi Low, thanks a million for answering! 1) reaction in short: Categories and materials are supposed to be 'ANY'. But 'material' must filter 'category'. What I mean is that 'Utemiljö' alone returns more results (=32) that 'Utemiljö' AND 'sten'. (=13) so that seems to be correct. 'Material' is a field in 2 channels that we search in this form. The content of that field is a series of 31 checkboxes. The values of these 31 checkboxes is the content of field (material_content) in another channel. That is why I search for 'material but the Low Options list targets material_content. – Hansl Nov 8 '16 at 20:07
  • 2) reaction in short. I corrected my code with your advise, but I still have missing results on certain values of 'materials'. It is the output of searched values that is the big problem here. My client must know which buttons they clicked when searching. I made a test entree with one of these missing values checked, NOW the search returned that value. When I delete that test entry, the error comes back. So that is why I still think there is something wrong..... Is it possible that I write you in person for a possible quote to solve this? Yours sincerely /Hans L. – Hansl Nov 8 '16 at 20:13
  • Yeah, this site isn't suited for back and forth support, so either open up a thread at GetSat or email me directly. – Low Nov 8 '16 at 20:22

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.