1

This is my first time trying to use Low Search for anything other than a simple keyword search and something isn't clicking.

I have a search form within a directory of member firms. There is a keyword field, as well as a drop down for states (US) and countries.

A few things worth noting:

  • The FIRMS channel has a matrix field ({cf_firm_location}) that has a VZ address column ("m_address").
  • If I search for a country (Ecuador => "EC") in the keywords, it comes up with the correct results. So that tells me that the matrix field / VZ Address column are properly set for searching.
  • If I try to search using the dropdown field for country, it returns ALL entries in the FIRMS channel (not sure why?)

Here is my SEARCH FORM:

{exp:low_search:form result_page="directory/search"}
<div><label for="keywords">Keywords</label> <input type="search" id="keywords" name="keywords" placeholder="Enter Search Phrase" size="18" maxlength="100" onblur="if (this.value=='') this.placeholder = 'Enter Search Phrase'" onfocus="if (this.placeholder=='Enter Search Phrase') this.value = ''" class="search-box rounded" /></div>
<div>
    <label for="search:cf_firm_location:m_address:region">State</label>
    <select name="search:cf_firm_location:m_address:region" id="search:cf_firm_location:m_address:region">
        <option value="">Please select....</option>
        <option value="AL">Alabama</option>
        <option value="AK">Alaska</option>
        <option value="AZ">Arizona</option>
        ......
    </select>
</div>
<div>
    <label for="search:cf_firm_location:m_address:country">Country</label>
    <select name="search:cf_firm_location:m_address:country" id="search:cf_firm_location:m_address:country">    
        <option value="">Please select....</option>
        <option value="AF">Afghanistan</option>
        <option value="AX">Aland Islands</option>
        <option value="AL">Albania</option>
        <option value="DZ">Algeria</option>
        ......  
    </select>
</div>
<div><button type="submit" class="tiny radius button search-button">Search</button></div>
{/exp:low_search:form}

Here is my SEARCH RESULTS:

{exp:low_search:results query="{segment_3}" require_query="yes" collection="firms" status="not closed" limit="10" paginate="bottom" orderby="title" sort="asc"}

<........ content here ............>

{/exp:low_search:results}

As always, any tips would be greatly appreciated!

2

As the docs for the Field Search filter state, the syntax to target a Grid or Matrix column is as follows:

search:field_name:column_name

So, the prefix search:, followed by the Matrix field name (cf_firm_location), followed by the column name (m_address).

Since you've got a fourth segment in there, probably a label that the Address field type uses, LS will not match the given name (which LS thinks is m_address:country) to the correct column.

Targeting a specific value for the Address field with the Field Search filter is not possible. It looks like VZ Address stores its data as a JSON string, so you could use the Field Search filter, but you're probably better off using the contains_words parameter as well (see how that would work in the EE docs).

As always with any Low add-on, turn on template debugging and look up all lines that mention the add-on name to see what's happening.

| improve this answer | |
  • Thanks Low. That 4th segment was the problem as I'm now getting results for the search for the country. However, now the results are not only finding locations with the country "EC" (example: Ecuador) but also with addresses that contain "ec". I'm guessing the only option I have is to split things out into separate columns in the Matrix - col_1 = address, col_2 = city, col_3 = state/region, col_4 = postal code, col_5 = country? – Todd Jul 5 '17 at 16:02
  • Just to confirm, I tested with separate columns for state / country, and the search works as expected! – Todd Jul 7 '17 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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