moduleArticle::Searchable extend ActiveSupport::Concern
includeddo include Elasticsearch::Model
# Customize the index name index_name"green_application"
# Set up index configuration and mapping settingsindex: { number_of_shards:1, number_of_replicas:0, analysis: { analyzer: { kuromoji_analyzer: { type:'custom', tokenizer:'kuromoji_tokenizer', filter: ['kuromoji_baseform','pos_filter','greek_lowercase_filter','cjk_width'], }, ngram_analyzer: { tokenizer:"ngram_tokenizer" } } } }do mapping_source: {enabled:true }, _all: {enabled:true,analyzer:"kuromoji_analyzer" }do indexes:id,type:'integer',index:'not_analyzed' indexes:title,type:'string',analyzer:'kuromoji_analyzer' # ... end end
defas_indexed_json(options={}) hash =self.as_json( include: { job_types: {only: [:job_type_id] }, # ... } ) hash['client_name'] = client.name
hash end end
moduleClassMethods defcreate_index!(options={}) client = __elasticsearch__.client client.indices.deleteindex:"green_application"rescuenilif options[:force] client.indices.createindex:"green_application", body: { settings: settings.to_hash, mappings: mappings.to_hash } end end end
|