The SearchFormHandler
class lets you specify multiple search types in a single request. For example, you can search on both keywords and text, or you can combine advanced searching with hierarchical searching to find only items in a particular category.
Search types are combined according to the following rules:
Text and keyword searches are combined with the OR operator, so a match on either set of criteria selects an item for inclusion in the search results.
Hierarchical and advanced searches are combined with the AND operator, limiting the scope of the search to items that satisfy the hierarchical or advanced search requirements in addition to any specified text or keyword search criteria.
The query can be expressed in this format:
(
KeywordConditions
OR
TextConditions
) AND
HierarchicalConditions
AND
AdvancedSearchConditions
For example, you have a set of recipes and you configure a SearchFormHandler
to allow all four types of searches. The site visitor enters the following search criteria:
keywords=appetizer
textSearchPropertyNames=ingredients
textInput="boston lettuce"
hierarchicalCategoryId=vegan
propertyValues.fatContent="5 grams"
The search locates all appetizers plus all recipes whose ingredients mention Boston lettuce, but returns only the subset of those recipes that are found in the vegan
category and have 5 grams of fat.