mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
[ongoing] migrate es api
This commit is contained in:
parent
b3f5edd1a5
commit
d69007c6c9
6
Gemfile
6
Gemfile
@ -122,9 +122,9 @@ gem 'recurrence'
|
||||
gem 'prawn'
|
||||
gem 'prawn-table'
|
||||
|
||||
gem 'elasticsearch-rails'
|
||||
gem 'elasticsearch-model'
|
||||
gem 'elasticsearch-persistence'
|
||||
gem 'elasticsearch-rails', '~> 5'
|
||||
gem 'elasticsearch-model', '~> 5'
|
||||
gem 'elasticsearch-persistence', '~> 5'
|
||||
|
||||
gem 'notify_with'
|
||||
|
||||
|
34
Gemfile.lock
34
Gemfile.lock
@ -154,24 +154,24 @@ GEM
|
||||
docile (1.1.5)
|
||||
domain_name (0.5.25)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
elasticsearch (1.0.12)
|
||||
elasticsearch-api (= 1.0.12)
|
||||
elasticsearch-transport (= 1.0.12)
|
||||
elasticsearch-api (1.0.12)
|
||||
elasticsearch (5.0.5)
|
||||
elasticsearch-api (= 5.0.5)
|
||||
elasticsearch-transport (= 5.0.5)
|
||||
elasticsearch-api (5.0.5)
|
||||
multi_json
|
||||
elasticsearch-model (0.1.7)
|
||||
elasticsearch-model (5.0.2)
|
||||
activesupport (> 3)
|
||||
elasticsearch (> 0.4)
|
||||
elasticsearch (~> 5)
|
||||
hashie
|
||||
elasticsearch-persistence (0.1.7)
|
||||
activemodel (> 3)
|
||||
activesupport (> 3)
|
||||
elasticsearch (> 0.4)
|
||||
elasticsearch-model (>= 0.1)
|
||||
elasticsearch-persistence (5.0.2)
|
||||
activemodel (> 4)
|
||||
activesupport (> 4)
|
||||
elasticsearch (~> 5)
|
||||
elasticsearch-model (~> 5)
|
||||
hashie
|
||||
virtus
|
||||
elasticsearch-rails (0.1.7)
|
||||
elasticsearch-transport (1.0.12)
|
||||
elasticsearch-rails (5.0.2)
|
||||
elasticsearch-transport (5.0.5)
|
||||
faraday
|
||||
multi_json
|
||||
equalizer (0.0.11)
|
||||
@ -217,7 +217,7 @@ GEM
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (0.9.1)
|
||||
concurrent-ruby (~> 1.0)
|
||||
ice_nine (0.11.1)
|
||||
ice_nine (0.11.2)
|
||||
jbuilder (2.5.0)
|
||||
activesupport (>= 3.0.0, < 5.1)
|
||||
multi_json (~> 1.2)
|
||||
@ -520,9 +520,9 @@ DEPENDENCIES
|
||||
database_cleaner
|
||||
devise
|
||||
devise-async
|
||||
elasticsearch-model
|
||||
elasticsearch-persistence
|
||||
elasticsearch-rails
|
||||
elasticsearch-model (~> 5)
|
||||
elasticsearch-persistence (~> 5)
|
||||
elasticsearch-rails (~> 5)
|
||||
faker
|
||||
figaro
|
||||
font-awesome-rails
|
||||
|
@ -98,13 +98,10 @@ class Project < ActiveRecord::Base
|
||||
def self.build_search_query_from_context(params, current_user)
|
||||
search = {
|
||||
query: {
|
||||
filtered: {
|
||||
filter: {
|
||||
bool: {
|
||||
must: [],
|
||||
should: []
|
||||
}
|
||||
}
|
||||
bool: {
|
||||
must: [],
|
||||
should: [],
|
||||
filter: [],
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,7 +109,7 @@ class Project < ActiveRecord::Base
|
||||
if params['q'].blank? # we sort by created_at if there isn't a query
|
||||
search[:sort] = { created_at: { order: :desc } }
|
||||
else # otherwise we search for the word (q) in various fields
|
||||
search[:query][:filtered][:query] = {
|
||||
search[:query][:bool][:must] << {
|
||||
multi_match: {
|
||||
query: params['q'],
|
||||
type: 'most_fields',
|
||||
@ -123,25 +120,25 @@ class Project < ActiveRecord::Base
|
||||
|
||||
params.each do |name, value| # we filter by themes, components, machines
|
||||
if name =~ /(.+_id$)/
|
||||
search[:query][:filtered][:filter][:bool][:must] << { term: { "#{name}s" => value } } if value
|
||||
search[:query][:bool][:filter] << { term: { "#{name}s" => value } } if value
|
||||
end
|
||||
end
|
||||
|
||||
if current_user and params.key?('from') # if use select filter 'my project' or 'my collaborations'
|
||||
if params['from'] == 'mine'
|
||||
search[:query][:filtered][:filter][:bool][:must] << { term: { author_id: current_user.id } }
|
||||
search[:query][:bool][:filter] << { term: { author_id: current_user.id } }
|
||||
end
|
||||
if params['from'] == 'collaboration'
|
||||
search[:query][:filtered][:filter][:bool][:must] << { term: { user_ids: current_user.id } }
|
||||
search[:query][:bool][:filter] << { term: { user_ids: current_user.id } }
|
||||
end
|
||||
end
|
||||
|
||||
if current_user # if user is connect, also display his draft projects
|
||||
search[:query][:filtered][:filter][:bool][:should] << { term: { state: 'published' } }
|
||||
search[:query][:filtered][:filter][:bool][:should] << { term: { author_id: current_user.id } }
|
||||
search[:query][:filtered][:filter][:bool][:should] << { term: { user_ids: current_user.id } }
|
||||
if current_user # if user is connected, also display his draft projects
|
||||
search[:query][:bool][:should] << { term: { state: 'published' } }
|
||||
search[:query][:bool][:should] << { term: { author_id: current_user.id } }
|
||||
search[:query][:bool][:should] << { term: { user_ids: current_user.id } }
|
||||
else # otherwise display only published projects
|
||||
search[:query][:filtered][:filter][:bool][:must] << { term: { state: 'published' } }
|
||||
search[:query][:bool][:must] << { term: { state: 'published' } }
|
||||
end
|
||||
|
||||
search
|
||||
|
@ -10,7 +10,8 @@ We've wrote a script to automate the process while keeping your data integrity,
|
||||
The script will try to add 4GB of swap memory if this requirement is detected as missing but this will consume you hard disk space (see below).
|
||||
- 1,17GB of free disk space are also required to perform the data migration.
|
||||
Please ensure that you'll have enough space, considering the point above. The script won't run otherwise.
|
||||
- This script will run on any Debian compatible OS (like Ubuntu) and on MacOS X, on any other systems you'll need to perform the upgrade yourself manually.
|
||||
- This script will run on any Linux or Macintoch systems if you installed ElasticSearch using docker or docker-compose.
|
||||
Otherwise, only Debian compatible OS (like Ubuntu) and MacOS X are supported for classical installations. On any other cases you'll need to perform the upgrade yourself manually.
|
||||
- If your ElasticSearch instance uses replicas shards, you can't use this script and you must perform a manual upgrade.
|
||||
|
||||
Once you've understood all the points above, you can run the migration script with the following:
|
||||
|
Loading…
x
Reference in New Issue
Block a user