diff options
author | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-07 16:41:36 +0200 |
---|---|---|
committer | Stephane Gamard <stephane.gamard@searchbox.com> | 2014-07-07 17:07:50 +0200 |
commit | 7bcc7926a9f6776288f118377eecc6de328eb25a (patch) | |
tree | a32b56b3f8d2c40b2db49900b755d96b6bbdc6e9 /sonar-server/src/main/java | |
parent | 0bf64521daeeaa777fee0c01f2fa4dc17dd85945 (diff) | |
download | sonarqube-7bcc7926a9f6776288f118377eecc6de328eb25a.tar.gz sonarqube-7bcc7926a9f6776288f118377eecc6de328eb25a.zip |
SONAR-5007 - Fixed hasDebt filter in RuleIndex
Conflicts:
sonar-server/src/test/java/org/sonar/server/rule/index/RuleIndexMediumTest.java
Diffstat (limited to 'sonar-server/src/main/java')
-rw-r--r-- | sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java index df2756104bc..3906b7f27fd 100644 --- a/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java +++ b/sonar-server/src/main/java/org/sonar/server/rule/index/RuleIndex.java @@ -58,7 +58,6 @@ import org.sonar.server.search.QueryOptions; import org.sonar.server.search.Result; import javax.annotation.CheckForNull; - import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -233,16 +232,16 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { if (debtCharacteristics != null && !debtCharacteristics.isEmpty()) { fb.must( FilterBuilders.orFilter( - // Match only when NOT NONE overriden + // Match only when NONE (overridden) FilterBuilders.andFilter( FilterBuilders.notFilter( FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), DebtCharacteristic.NONE)), FilterBuilders.orFilter( FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), debtCharacteristics), FilterBuilders.termsFilter(RuleNormalizer.RuleField.CHARACTERISTIC.field(), debtCharacteristics)) - ), + ), - // Match only when NOT NONE overriden + // Match only when NOT NONE (not overridden) FilterBuilders.andFilter( FilterBuilders.orFilter( FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), ""), @@ -250,14 +249,19 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { FilterBuilders.orFilter( FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_SUB_CHARACTERISTIC.field(), debtCharacteristics), FilterBuilders.termsFilter(RuleNormalizer.RuleField.DEFAULT_CHARACTERISTIC.field(), debtCharacteristics))) - ) - ); + ) + ); } // Debt char exist filter Boolean hasDebtCharacteristic = query.getHasDebtCharacteristic(); if (hasDebtCharacteristic != null && hasDebtCharacteristic) { - fb.must(FilterBuilders.existsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field())); + fb.mustNot( + FilterBuilders.termsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field(), DebtCharacteristic.NONE)) + .should( + FilterBuilders.existsFilter(RuleNormalizer.RuleField.SUB_CHARACTERISTIC.field())) + .should( + FilterBuilders.existsFilter(RuleNormalizer.RuleField.DEFAULT_SUB_CHARACTERISTIC.field())); } if (query.getAvailableSince() != null) { |