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

Support archive

How to search specific fields?

Jonno2112 14 Nov 2011 12:40 question, complete

How do I search specific fields within a channel? I have a property site which has fields like so:
property_description
property_floorspace
property_region
etc

I have form fields named the same, how do I, for example, make the property_description form field search the property_description channel field only?

Sorry if this is a dumb ass question, i just can't get it to work.

Replies

  1. Low 14 Nov 2011 13:32

    If you want to search separate custom fields using keywords, you'll have to create separate collections for each of those, only adding weight to the searchable field. Then select which collection you want to search through instead of which custom field.

    You could also use the search:custom_field syntax, which is used to add the search:custom_field="example" parameter to the search results tag. I do not recommend using free text input fields for these parameters, but rather pre-populated drop downs or radio buttons. For example, if your "property_region" variable contains a fixed number of values, that would be ideal for a pre-populated drop down:

    <select name="search:property_region"> 
    <option value="foo">Foo</option>
    ...
    </select>