forked from Trustie/forgeplus
新增: es配置
This commit is contained in:
parent
66c40d4791
commit
09f0341883
3
Gemfile
3
Gemfile
|
|
@ -128,3 +128,6 @@ gem 'harmonious_dictionary', '~> 0.0.1'
|
|||
gem 'parallel', '~> 1.19', '>= 1.19.1'
|
||||
|
||||
gem 'letter_avatar'
|
||||
|
||||
gem 'elasticsearch-model', github: 'elastic/elasticsearch-rails', branch: 'main'
|
||||
gem 'elasticsearch-rails', github: 'elastic/elasticsearch-rails', branch: 'main'
|
||||
13
Gemfile.lock
13
Gemfile.lock
|
|
@ -1,3 +1,14 @@
|
|||
GIT
|
||||
remote: https://github.com/elastic/elasticsearch-rails.git
|
||||
revision: b66fe71cc4b9b10069bf6d39dbbfcc0b117a08a5
|
||||
branch: main
|
||||
specs:
|
||||
elasticsearch-model (7.2.1)
|
||||
activesupport (> 3)
|
||||
elasticsearch (~> 7)
|
||||
hashie
|
||||
elasticsearch-rails (7.2.1)
|
||||
|
||||
GEM
|
||||
remote: https://gems.ruby-china.com/
|
||||
specs:
|
||||
|
|
@ -450,6 +461,8 @@ DEPENDENCIES
|
|||
chromedriver-helper
|
||||
deep_cloneable (~> 3.0.0)
|
||||
diffy
|
||||
elasticsearch-model!
|
||||
elasticsearch-rails!
|
||||
enumerize
|
||||
faraday (~> 0.15.4)
|
||||
font-awesome-sass (= 4.7.0)
|
||||
|
|
|
|||
|
|
@ -79,9 +79,8 @@
|
|||
#
|
||||
|
||||
|
||||
|
||||
|
||||
class Project < ApplicationRecord
|
||||
include Elasticsearch::Model
|
||||
include Matchable
|
||||
include Publicable
|
||||
include Watchable
|
||||
|
|
|
|||
|
|
@ -67,6 +67,11 @@ default: &default
|
|||
domain: ''
|
||||
base_url: ''
|
||||
|
||||
es:
|
||||
url: 'http://localhost:9200'
|
||||
user: 'elastic'
|
||||
password: '123456'
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
# 中间层地址
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
require 'elasticsearch/model'
|
||||
|
||||
es_config = Rails.application.config_for(:es)
|
||||
host_url = es_config["url"] || 'http://localhost:9200/'
|
||||
user = es_config["user"] || ''
|
||||
password = es_config["password"] || ''
|
||||
|
||||
Elasticsearch::Model.client = Elasticsearch::Client.new user: user, password: password, host: host_url
|
||||
Loading…
Reference in New Issue