aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlec Warner <antarus@gentoo.org>2018-02-18 19:12:46 -0500
committerAlec Warner <antarus@gentoo.org>2018-02-18 19:12:46 -0500
commitc8e4763d761f646b2e1b1129522c60cc8c38f07e (patch)
treeb8ce182c091b2e5960e2969e10f9169348b76560
parentAlso fix ES name, default to localhost. (diff)
downloadpackages-5-c8e4763d761f646b2e1b1129522c60cc8c38f07e.tar.gz
packages-5-c8e4763d761f646b2e1b1129522c60cc8c38f07e.tar.bz2
packages-5-c8e4763d761f646b2e1b1129522c60cc8c38f07e.zip
Push the size param into the aggregation part.v6.0.2
According to https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html this controls the number of buckets (defaulting to 10 apparently). This was changed in ES5 but went unnoticed until now. Force to 10k buckets to continue to support flags with *lots* of packages and revisit in the future if too expensive.
-rw-r--r--lib/kkuleomi/store/models/package_search.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/kkuleomi/store/models/package_search.rb b/lib/kkuleomi/store/models/package_search.rb
index 263eb25..ec0268c 100644
--- a/lib/kkuleomi/store/models/package_search.rb
+++ b/lib/kkuleomi/store/models/package_search.rb
@@ -30,7 +30,7 @@ module Kkuleomi::Store::Models::PackageSearch
# Results are aggregated by package atoms.
def find_atoms_by_useflag(useflag)
Version.search(
- size: 10000, # default limit is 10.
+ size: 0, # collect all packages.
query: {
bool: {
must: { match_all: {} },
@@ -41,11 +41,14 @@ module Kkuleomi::Store::Models::PackageSearch
group_by_package: {
terms: {
field: 'package',
- order: { '_key' => 'asc' }
+ order: { '_key' => 'asc' },
+ # https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html
+ # ES actually dislikes large sizes like this (it defines 10k buckets basically) and it will be *very* expensive but lets try it and see.
+ # Other limits in this app are also 10k mostly to 'make things fit kinda'.
+ size: 10000,
}
}
},
- size: 0
).response.aggregations['group_by_package'].buckets
end