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

Support archive

Is it possible to build a search form with TWO keyword fields?

David Lang 10 Feb 2013 16:56 question, complete

I just purchased LS and I'm still learning, my apologies in advance if i'm asking a stupid question.

Is it possible to perfom a search with two keyword fields searching two different fields? I'd like to search a title-field AND a custom field, much like combining a keyword-field and a category-select.

If a category-select has too much entries (300+ in my case), it quite useless. So i would like to have a second input field, enabling me to perform a search

WHERE field_value_of_title_field == input_field_1 AND field_value_of_custom_field == input_field_2.

Example: http://www.monster.co.uk/

Is this possible at all? Or do I need to get down and dirty with PHP?

Replies

  1. Low 11 Feb 2013 08:48

    Low Search keywords will search the index to filter entries. The index itself doesn't differentiate between fields. You can build different collections where fields are weighted differently, but that still won't give you the results you're looking for.

    Instead, you'd have to resort to the search:field option. This isn't as sophisticated as the LS Keyword search, but does allow you to target specific fields.

    So, you could create a collection with either just the title or the custom field weighted, then use these input fields:

    <input name="keywords" /> (searches collection) 
    <input name="search:title" /> (searches title only)


    or

    <input name="keywords" /> (searches collection) 
    <input name="search:custom_field" /> (searches field only)