From 32a04e55759c761e2148bb3cbde0b383732069e7 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 16 Jan 2017 20:01:23 -0800 Subject: [PATCH] Use movies for autocomplete example [skip ci] --- README.md | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2474cae..475757b 100644 --- a/README.md +++ b/README.md @@ -602,15 +602,15 @@ Before getting started, a few good things to know: If the above situations don’t apply, let’s continue. First, specify which fields use this feature. This is necessary since autocomplete can increase the index size significantly, but don’t worry - this gives you blazing faster queries. ```ruby -class Book < ActiveRecord::Base - searchkick word_start: [:title, :author] +class Movie < ActiveRecord::Base + searchkick word_start: [:title, :director] end ``` Reindex and search with: ```ruby -Book.search "tipping poi", match: :word_start +Movie.search "jurassic pa", match: :word_start ``` Typically, you want to use a JavaScript library like [typeahead.js](http://twitter.github.io/typeahead.js/) or [jQuery UI](http://jqueryui.com/autocomplete/). @@ -620,11 +620,10 @@ Typically, you want to use a JavaScript library like [typeahead.js](http://twitt First, add a route and controller action. ```ruby -# app/controllers/books_controller.rb -class BooksController < ApplicationController +class MoviesController < ApplicationController def autocomplete - render json: Book.search(params[:query], { - fields: ["title^5", "author"], + render json: Movie.search(params[:query], { + fields: ["title^5", "director"], match: :word_start, limit: 10, load: false, @@ -642,16 +641,16 @@ Then add the search box and JavaScript code to a view. ``` -- libgit2 0.21.0