Introduction to Searching

Scrivito includes search functionality you can use directly in your Rails application, i.e. without having to configure or maintain your own search engine. All searches are carried out by Elasticsearch, which is based on Apache Lucene. Elasticsearch is fast, highly scalable and available, and offers a versatile query syntax. This makes Elasticsearch an ideal background search service for your Scrivito-based Rails application.

Scrivito builds a dedicated search index for every working copy, so the findability of new content can be tested while the content is produced.

Search functionality is made available to your app through the “Obj.where" class method the Scrivito SDK provides. If you have a Scrivito app and a couple of web pages, i.e. CMS objects, you can easily try it out. Open a Rails console and run:

> Obj.where(:*, :contains, 'company').first => <Homepage id="5a5f98205b415dc5" path="/en">

Searches can be refined using logical operators (“and”, “and_not”), and search results can be ordered by any CMS object attribute. See the Search API Examples or the API documentation for details.