|
Search Indexes are a feature of the Chef Server that allow you to use a full text search engine (currently based on Ferret) to store and query information about your infrastructure and applications.
|
Table of Contents |
The Node Index
By default, we create a search index called node for all of your Nodes. This index has all of the attributes and recipes for your nodes, and allows you to search them. It uses a simple "hash flattening" technique to create the field names for the index. For example, if you had a Node with the following attributes:
We would create an Index object with the following fields:
The basic gist here is simple - we take the keys of a nested hash and join them together with _.
The search syntax
The search indexes use the default Ferret search query syntax (FQL). Some basic examples of using the FQL in a recipe:
The Web UI
You can play with the search indexes most easily via the Chef Server Web UI.
- Log in to your Chef Server with your OpenID by hitting the 'Login' link.
- Click 'Search'
- Put your query into the Query field for the Node index.
- If you want specific attributes only, list them in the Attributes field, separated by commas.
- Click 'Search node'
- Rejoice!
Creating custom search indexes
Currently, you can only create custom search indexes via the REST API. Here is an example, which creates a "user" index based on my Mac laptop's /etc/passwd file:
Running that script will create a user index, and allow you to search on it. (Just try placing :user in a recipe rather than :node)