Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f940af1
Change client to conditionally use different hosts
maxwxzheng Nov 6, 2017
852faa9
Update all places necessary to use conditional host names.
maxwxzheng Nov 7, 2017
1072cc4
Fix a bug where we are not passing hosts name to the version call
maxwxzheng Nov 7, 2017
663b7ab
Merge remote-tracking branch 'upstream/master'
maxwxzheng Dec 24, 2019
e5c526a
Fix request.rb _indices
maxwxzheng Dec 25, 2019
8156b64
Add host_name to some query client calls
maxwxzheng Dec 25, 2019
cc251e7
Changes to support es 7
maxwxzheng Dec 31, 2019
8af16f5
Remove changes on delete_all
maxwxzheng Jan 4, 2020
d1523ab
Merge post_filter into query if counting total
maxwxzheng Mar 18, 2020
15de427
print
3mammoth Mar 23, 2020
d8f4818
fix
3mammoth Mar 23, 2020
bc68de0
add logging
3mammoth Mar 23, 2020
eeed671
add more logging
3mammoth Mar 23, 2020
ef9f577
mabe fix bug
3mammoth Mar 23, 2020
dd5e2c1
delete putss
3mammoth Mar 23, 2020
e1fc580
track_total_hits
3mammoth Apr 13, 2020
258c5f1
track_total_hits
3mammoth Apr 13, 2020
3cdc21e
Support x-opaque-id
maxwxzheng May 3, 2020
d817ed1
Prevent double query
mightymercado May 14, 2021
5d7d0e3
Skip those with indexable criteria for now
mightymercado May 14, 2021
a708693
allow passing of searchable proc
mightymercado May 14, 2021
3f8ff3c
Merge pull request #2 from apolloio/ken/prevent-query
mightymercado May 14, 2021
56c954f
fix searchable proc passing
mightymercado May 14, 2021
e19cfe4
Merge pull request #3 from apolloio/ken/prevent-query
mightymercado May 14, 2021
a26eeeb
Delete non indexable documents
mightymercado May 18, 2021
7c360f4
Merge pull request #5 from apolloio/ken/delete-non-indexable-people
mightymercado May 19, 2021
dce35eb
Fix ruby 2.7 deprecation warnings
jaywonder20 Jul 28, 2021
f60be63
more fixes
jaywonder20 Jul 28, 2021
7e1fe93
fix
jaywonder20 Aug 7, 2021
cb10905
Merge pull request #6 from apolloio/jerry/upgrade
3mammoth Aug 19, 2022
a361d16
Merge tag 'tags/v7.3.3' into farhad/sync-upstream
RafikFarhad Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/.rakeTasks

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions .idea/chewy.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions lib/chewy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def derive_name(index_name)
def client
Chewy.current[:chewy_client] ||= begin
client_configuration = configuration.deep_dup
if hosts
client_configuration[:hosts] = client_configuration[hosts]
end
client_configuration.delete(:prefix) # used by Chewy, not relevant to Elasticsearch::Client
block = client_configuration[:transport_options].try(:delete, :proc)
::Elasticsearch::Client.new(client_configuration, &block)
Expand All @@ -119,6 +122,7 @@ def wait_for_status
# Be careful, if current prefix is blank, this will destroy all the indexes.
#
def massacre
# TODO(Max): Add hosts to this client call
Chewy.client.indices.delete(index: [Chewy.configuration[:prefix], '*'].reject(&:blank?).join('_'))
Chewy.wait_for_status
end
Expand Down
9 changes: 9 additions & 0 deletions lib/chewy/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Index
self._default_import_options = {}

class << self
attr_reader :hosts_name

# @overload index_name(suggest)
# If suggested name is passed, it is set up as the new base name for
# the index. Used for the index base name redefinition.
Expand Down Expand Up @@ -92,6 +94,13 @@ def index_name(suggest = nil, prefix: nil, suffix: nil)
end
end

# Sets the hosts name of the index. If hosts_name is nil, use the default
# hosts in chewy.yml. Otherwise use the hosts with the specified name for
# indexing/queries.
def set_hosts_name(hosts_name)
@hosts_name = hosts_name
end

# Base name for the index. Uses the default value inferred from the
# class name unless redefined.
#
Expand Down
10 changes: 5 additions & 5 deletions lib/chewy/index/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module ClassMethods
# UsersIndex.exists? #=> true
#
def exists?
client.indices.exists(index: index_name)
client(@hosts_name).indices.exists(index: index_name)
end

# Creates index and applies mappings and settings.
Expand Down Expand Up @@ -59,7 +59,7 @@ def create!(suffix = nil, **options)

body = specification_hash
body[:aliases] = {general_name => {}} if options[:alias] && suffixed_name != general_name
result = client.indices.create(index: suffixed_name, body: body)
result = client(@hosts_name).indices.create(index: suffixed_name, body: body)

Chewy.wait_for_status if result
result
Expand Down Expand Up @@ -164,13 +164,13 @@ def reset!(suffix = nil, apply_journal: true, journal: false, **import_options)
original_index_settings suffixed_name

delete if indexes.blank?
client.indices.update_aliases body: {actions: [
client(@hosts_name).indices.update_aliases body: {actions: [
*indexes.map do |index|
{remove: {index: index, alias: general_name}}
end,
{add: {index: suffixed_name, alias: general_name}}
]}
client.indices.delete index: indexes if indexes.present?
client(@hosts_name).indices.delete index: indexes if indexes.present?

self.journal.apply(start_time, **import_options) if apply_journal
result
Expand Down Expand Up @@ -255,7 +255,7 @@ def original_index_settings(index_name)
end

def update_settings(index_name, **options)
client.indices.put_settings index: index_name, body: {index: options[:settings]}
client(@hosts_name).indices.put_settings index: index_name, body: {index: options[:settings]}
end

def index_settings(setting_name)
Expand Down
Loading