Opscode
Home     Cookbooks     Blog     GitHub     Tickets 

Search Indexes

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.

In flux!

This feature, while really cool today, is going to get much cooler in ways that might make the current interface incompatible. We won't be removing any functionality, but the interface might change - and might change dramatically. We'll remove this warning when it's no longer in flux. You should go ahead and use the search feature today - just remember that you'll probably need to do some re-factoring later when we make it better. Also, the creation and management of custom indexes is relatively untested - we know it works at a basic level, but it's not been used past the toy level.

Chef 0.8 Changes

The search engine in the upcoming Chef 0.8 release is SOLR, instead of Ferret. There are also syntax changes to search statements as posted by Adam Jacob to the Chef Developer list. This change improves performance, reliability and capability of the search index feature.

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:

Node

We would create an Index object with the following fields:

Indexed Node

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:

Search examples

The Web UI

You can play with the search indexes most easily via the Chef Server Web UI.

  1. Log in to your Chef Server with your OpenID by hitting the 'Login' link.
  2. Click 'Search'
  3. Put your query into the Query field for the Node index.
  4. If you want specific attributes only, list them in the Attributes field, separated by commas.
  5. Click 'Search node'
  6. 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:

User Index

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)

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

Copyright © 2009 Opscode, Inc. All Rights Reserved.