我不知道如何通过 Tire gem 使用 Elasticsearch 的同义词/复数。我有一个要下载的同义词文件(一个英文就够了)吗?无论我是否使用轮胎,都需要在 ES 中进行设置吗?
class Story < ActiveRecord::Base
include Tire::Model::Search
include Tire::Model::Callbacks
attr_accessible :author, :content, :title
mapping do
indexes :id, :index => :not_analyzed
indexes :author, :analyzer => 'keyword'
indexes :title, :analyzer => 'snowball'
indexes :content, :analyzer => 'snowball'
end
end
class StoriesController < ApplicationController
def index
if params[:q].present?
p = params
@stories = Story.search(per_page: 30, page: params[:page], load: true) do
query { string p[:q], default_operator: 'AND' }
end
end
end
end
我在文档中什么也没找到...
谢谢!