2019-07-08 21:06:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-07-08 15:46:34 -04:00
|
|
|
# Be sure to restart your server when you modify this file.
|
|
|
|
|
|
|
|
require 'gitlab/current_settings'
|
|
|
|
|
|
|
|
Gitlab.ee do
|
2019-07-31 09:00:49 -04:00
|
|
|
require 'elasticsearch/model'
|
|
|
|
|
2019-12-05 07:07:43 -05:00
|
|
|
### Monkey patches
|
|
|
|
|
|
|
|
Elasticsearch::Model::Response::Records.prepend GemExtensions::Elasticsearch::Model::Response::Records
|
|
|
|
Elasticsearch::Model::Adapter::Multiple::Records.prepend GemExtensions::Elasticsearch::Model::Adapter::Multiple::Records
|
|
|
|
Elasticsearch::Model::Indexing::InstanceMethods.prepend GemExtensions::Elasticsearch::Model::Indexing::InstanceMethods
|
|
|
|
Elasticsearch::Model::Adapter::ActiveRecord::Importing.prepend GemExtensions::Elasticsearch::Model::Adapter::ActiveRecord::Importing
|
2020-07-27 14:09:54 -04:00
|
|
|
Elasticsearch::Model::Adapter::ActiveRecord::Records.prepend GemExtensions::Elasticsearch::Model::Adapter::ActiveRecord::Records
|
2019-12-05 07:07:43 -05:00
|
|
|
Elasticsearch::Model::Client::InstanceMethods.prepend GemExtensions::Elasticsearch::Model::Client
|
|
|
|
Elasticsearch::Model::Client::ClassMethods.prepend GemExtensions::Elasticsearch::Model::Client
|
|
|
|
Elasticsearch::Model::ClassMethods.prepend GemExtensions::Elasticsearch::Model::Client
|
|
|
|
Elasticsearch::Model.singleton_class.prepend GemExtensions::Elasticsearch::Model::Client
|
|
|
|
|
2021-11-15 16:14:31 -05:00
|
|
|
### Modified from elasticsearch-model/lib/elasticsearch/model/searching.rb
|
|
|
|
|
|
|
|
module Elasticsearch
|
|
|
|
module Model
|
|
|
|
module Searching
|
|
|
|
class SearchRequest
|
|
|
|
def execute!
|
|
|
|
response = klass.client.search(@definition)
|
|
|
|
raise Elastic::TimeoutError if response['timed_out']
|
|
|
|
|
|
|
|
response
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-31 09:00:49 -04:00
|
|
|
### Modified from elasticsearch-model/lib/elasticsearch/model.rb
|
|
|
|
|
|
|
|
[
|
|
|
|
Elasticsearch::Model::Client::ClassMethods,
|
|
|
|
Elasticsearch::Model::Naming::ClassMethods,
|
|
|
|
Elasticsearch::Model::Indexing::ClassMethods,
|
|
|
|
Elasticsearch::Model::Searching::ClassMethods
|
|
|
|
].each do |mod|
|
|
|
|
Elasticsearch::Model::Proxy::ClassMethodsProxy.include mod
|
|
|
|
end
|
|
|
|
|
|
|
|
[
|
|
|
|
Elasticsearch::Model::Client::InstanceMethods,
|
|
|
|
Elasticsearch::Model::Naming::InstanceMethods,
|
|
|
|
Elasticsearch::Model::Indexing::InstanceMethods,
|
|
|
|
Elasticsearch::Model::Serializing::InstanceMethods
|
|
|
|
].each do |mod|
|
|
|
|
Elasticsearch::Model::Proxy::InstanceMethodsProxy.include mod
|
|
|
|
end
|
|
|
|
|
|
|
|
Elasticsearch::Model::Proxy::InstanceMethodsProxy.class_eval <<-CODE, __FILE__, __LINE__ + 1
|
|
|
|
def as_indexed_json(options={})
|
|
|
|
target.respond_to?(:as_indexed_json) ? target.__send__(:as_indexed_json, options) : super
|
|
|
|
end
|
|
|
|
CODE
|
2019-07-08 15:46:34 -04:00
|
|
|
end
|