New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix document counts with an empty index set #3291

Merged
merged 4 commits into from Jan 4, 2017

Conversation

Projects
None yet
2 participants
@bernd
Member

bernd commented Jan 3, 2017

Return 0 if there are no indices in the given index set. If we run the query with an empty index list, Elasticsearch will count all documents in all indices and thus return a wrong count.

@bernd bernd added this to the 2.2.0 milestone Jan 3, 2017

@joschi joschi self-assigned this Jan 3, 2017

@joschi

I guess this will create a merge conflict with #3288 (just FYI).

@@ -45,6 +45,12 @@ public long total() {
public long total(final IndexSet indexSet) {
final String[] names = indexSet.getManagedIndicesNames();
// Return 0 if there are no indices in the given index set. If we run the query with an empty index list,
// Elasticsearch will count all documents in all indices and thus return a wrong count.
if (names.length == 0) {

This comment has been minimized.

@joschi

joschi Jan 3, 2017

Contributor

This check should probably also be added to the Counts#total() method.

If none of the index set contains an index and other indices (not managed by Graylog) exist in the Elasticsearch cluster, the returned value might be wrong.

This comment has been minimized.

@bernd

bernd Jan 3, 2017

Member

Good point, fixed. 👍

// Return 0 if there are no indices in the given index set. If we run the query with an empty index list,
// Elasticsearch will count all documents in all indices and thus return a wrong count.
if (names.length == 0) {
if (requireNonNull(indexNames).length == 0) {

This comment has been minimized.

@joschi

joschi Jan 3, 2017

Contributor

Why the requireNonNull() here?

If indexNames is null, it will throw an NPE anyway.

@bernd bernd force-pushed the fix-index-counts branch to aa3d2e7 Jan 3, 2017

@joschi

joschi approved these changes Jan 4, 2017

@joschi joschi merged commit f17c81e into master Jan 4, 2017

4 checks passed

ci-web-linter Jenkins build graylog-pr-linter-check 1240 has succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
licence/cla Contributor License Agreement is signed.
Details

@joschi joschi deleted the fix-index-counts branch Jan 4, 2017

@joschi joschi removed the ready-for-review label Jan 4, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment