Search Multiple Fields in a form with other field searches using one keyword input using collection
This is for one field in an advanced search form that has multiple dropdown category selectors and a few keyword inputs. This is the field which I would like to also search the entry title.
''
If I try something like:
''
The results page returns an error. Is there a way to do this? I did create a collection that only has values for those fields but I'm not clear on how to reference that collection in the input. The overall search tag has multiple collections in the exp:low_search:form collections parameter.
The site is running Low Search v4.4.5 with ExpressionEngine 2.7.3
Replies
Low 23 Oct 2018 18:26
Not sure I follow; GetSat stripped away any code. Can you try again, maybe use http://pastebin.com/ for large chunks of code.
smartpill 23 Oct 2018 19:29
Oh, yeah that's no good. ;-)
https://pastebin.com/X7LSmyks
Low 24 Oct 2018 06:01
If you want to search multiple fields with keywords, you'd have to use the Keywords filter. So, use
along with a collection parameter (or leave empty for all collections). You said you've already created a collection for the combined fields, so you could use
or just hard-code it on the Results tag:
smartpill 24 Oct 2018 17:15
In the input I used:
type="text" collection="ctm_comp_names" name="keywords" value="{low_search_keywords}"
I tried the collection parameter with just a single number and with the Collection Name. Seems to search the entry titles fine but the custom field which is a matrix field is not searched. If I only specify the matrix field it works. If I don't specify any collection name it doesn't work.
Low 24 Oct 2018 18:05
The Matrix field needs to be searchable itself, and has at least one searchable column defined in the field's settings. Then you can assign weight to it in the LS Collection details.
Note that if the Matrix field wasn't searchable to begin with, you will need to re-save each entry to populate the actual searchable data. A bit of a pain, but there's no real way around it.
Once that's done and you've created the collection, you can build the collection's index.
To search that specific collection, you need 2 parameters: keywords and collection.
Using an input field like this, using regular old HTML:
...won't do anything with the collection="" attribute. It's an custom attribute to an input element, is all. Check the docs on parameters again, you'll see that syntax doesn't make sense.
Instead, as stated in the docs, either use an input field in a LS Form per parameter like this:
...or move the collection parameter to the Results tag, using EE's parameter syntax we all know: