Creating a search view
First create a Search server and Search index as per the directions in the previous section. In the index make sure that you enable the status field in order to allow Views to filter on the Published status.
Enable the search_api_views submodule.
Set up a display mode (optional)
I'm going to use the 'Search results' display mode–this means that I won't be using Views to configure which fields are displayed. This is of course at your own personal preference. If you want to use views you probably know what you are doing and you'll have to amend the following steps somewhat.
Structure > Content types >
[node type] > Manage display > Custom display settings
Enable “search results”
Configure display fields.
Create a new View
Admin > Structure > Views > Add new view
- View name: Search
- Show: [the name of the Search index] (in the case of fuzzysearch the default is "Default fuzzysearch index")
- Create a page [tick]
- Page title: Search
- Path: search
- Display format: Unformatted list of Rendered entity
- Items to display: 10, use pager
Continue & edit (the new View)
Format: Show: Rendered entity | Settings
- View mode: Search results
- Fulltext search: Expose this filter, Required, Remember the last selection, Use as: search keys
- Search: Relevance, descending (if you don’t have an order with fuzzysearch you will get a PDO exception)
- Access: Permission: view published content
- No results behaviour: Global: Text area “No results matched your search.”
- Exposed form in block: Yes (This option will only show up on Page displays.)
- Exposed form style settings: Submit button text: Search
Save the View. Add the exposed form block to a region.
Note that you will only receive results for partial matches that are longer than the minimum word length specified in the Index configuration.