aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2018-01-15 19:30:01 -0500
committerAlec Warner <antarus@gentoo.org>2018-01-15 19:30:01 -0500
commit5f40a6faaf4b57ad264b31c7159042a126b0f5fe (patch)
treeb45bc9b410a4ad11e17b8a2767b1c3f31b945ebc
parentUpdate Elasticsearch gems to 6.0.0 (diff)
downloadpackages-5-5f40a6faaf4b57ad264b31c7159042a126b0f5fe.tar.gz
packages-5-5f40a6faaf4b57ad264b31c7159042a126b0f5fe.tar.bz2
packages-5-5f40a6faaf4b57ad264b31c7159042a126b0f5fe.zip
Update elasticsearch queries.
Similar to the previous commit: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html documents that query => filtered semantic is deprecated. This fixes more references.
-rw-r--r--config/initializers/elasticsearch.rb4
-rw-r--r--lib/kkuleomi/store/model.rb10
2 files changed, 6 insertions, 8 deletions
diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb
index 9be3660..71a032a 100644
--- a/config/initializers/elasticsearch.rb
+++ b/config/initializers/elasticsearch.rb
@@ -1,10 +1,10 @@
require 'elasticsearch/persistence/model'
-Elasticsearch::Persistence.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || 'localhost:9200'
+Elasticsearch::Persistence.client = Elasticsearch::Client.new host: ENV['ELASTICSEARCH_URL'] || 'elasticsearch:9300'
if Rails.env.development?
logger = ActiveSupport::Logger.new(STDERR)
logger.level = Logger::INFO
logger.formatter = proc { |s, d, p, m| "\e[2m#{m}\n\e[0m" }
Elasticsearch::Persistence.client.transport.logger = logger
-end \ No newline at end of file
+end
diff --git a/lib/kkuleomi/store/model.rb b/lib/kkuleomi/store/model.rb
index 8d406bf..e610ada 100644
--- a/lib/kkuleomi/store/model.rb
+++ b/lib/kkuleomi/store/model.rb
@@ -9,9 +9,7 @@ module Kkuleomi::Store::Model
def find_all_by(field, value, opts = {})
search({
size: 10_000,
- query: {
- filtered: { filter: { term: { field => value } } }
- }
+ query: { bool: { filter: { term: { field => value } } }
}.merge(opts))
end
@@ -22,7 +20,7 @@ module Kkuleomi::Store::Model
search({
query: {
- filtered: { filter: { bool: { must: filter_args } } }
+ bool: { filter: { bool: { must: filter_args } } }
},
size: 10_000
}.merge(opts))
@@ -36,14 +34,14 @@ module Kkuleomi::Store::Model
search(opts.merge(
size: 10_000,
query: {
- filtered: {
+ bool: {
filter: {
has_parent: {
type: parent.class.document_type,
filter: { term: { _id: parent.id } }
}
},
- query: { match_all: {} }
+ must: { match_all: {} }
}
}
))