20.1. Searching Overview

You will be creating two types of search capabilities.

The first is a keyword search. You perform this type of search by sending a list of keywords containing the search terms separated by spaces.

The second is a category search. You perform this type of search by sending a category id to the search service, which will return all posts in that category.

Both types of searches have the following requirements:

  • They must return a list of post titles matching the search results, which the user can use to select a post.

  • It should be clear to the user what type of search results he or she is viewing.

  • There must be a mechanism to allow the user to clear the search results and hide the view.

Executing a keyword search is a matter of passing the search string to the Cairngorm classes responsible for performing the search. All you need to do is provide the user with a method of specifying keywords and take these and pass them to your Cairngorm classes.

The category search requires that the user once again be able to select a category and that the categoryId be retrieved based on that selection. You have already done something similar for the add post feature. This categoryId will then be passed on to your Cairngorm classes to perform the search.

Clearing the search results is a matter of removing the items from the property on the model representing the search results and hiding the search results view.

Get Professional Cairngorm™ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.