The (not always) Simple Search Form
by Ryan Irelan
If you’ve implemented the Simple Search Form before, you’ve probably come across this. For me, it’s the small thing that I usually forget until I go to test some search terms to make sure the search functionality is working as expected and the results have the proper URLs.
So what am I talking about?
The search_in
parameter. The Simple Search Form defaults to only searching in the entry titles of the weblog(s) you specify. It says so right there in the documentation:
If this parameter is not set, the search will default to only search by “titles”.
It doesn’t make much practical sense to me that the default behavior for site search would be so limited, but there it is. It does make technical sense; the more limited the search, the faster the queries.
There are three possible values for the search_in
parameter:
1. entries: The search will be conducted in the entry fields and titles of your weblog. The associated comments will not be included.
2. everywhere: The search will be conducted in the title, entry fields, and in associated comments.
3. titles: The search will be conducted in the title of your entries. The weblog entry fields and any associated comments will not be included.
A good value to use is entries
, as that allows your site visitors to search in all of your weblog fields (as long as you allow it explicitly when setting up the custom field) but doesn’t burden the search with searching through all of the comments of your entries.
Here’s the Simple Search Form EE code for this site:
{exp:search:simple_form weblog="blog|articles|videos"
result_page="search/results" search_in="entries"}
. . .
{/exp:search:simple_form}