]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8287 Project measure value is a double in ES index 1308/head
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Tue, 18 Oct 2016 13:06:00 +0000 (15:06 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Tue, 18 Oct 2016 15:01:47 +0000 (17:01 +0200)
server/sonar-server/src/main/java/org/sonar/server/component/es/ProjectMeasuresIndexDefinition.java
server/sonar-server/src/test/java/org/sonar/server/component/es/ProjectMeasuresIndexTest.java

index 6fab7e61841ba877572a92fd03e1c093a6e9a353..a8ba6675e5949a0ba4a816b37e9b0fdbb29a78de 100644 (file)
@@ -52,7 +52,7 @@ public class ProjectMeasuresIndexDefinition implements IndexDefinition {
     mapping.createDateTimeField(FIELD_ANALYSED_AT);
     mapping.nestedFieldBuilder(FIELD_MEASURES)
       .addStringFied(FIELD_MEASURES_KEY)
-      .addStringFied(FIELD_MEASURES_VALUE)
+      .addDoubleField(FIELD_MEASURES_VALUE)
       .build();
 
     // do not store document but only indexation of information
index b47e5832bd2f50228ee95ed003c7e4feae574c2e..2306d6c18a844543af6eea540106de420cbbd895 100644 (file)
@@ -93,15 +93,14 @@ public class ProjectMeasuresIndexTest {
   @Test
   public void filter_with_greater_than() {
     addDocs(
-      newDoc("P1", "K1", "N1").setMeasures(newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_000d))),
-      newDoc("P2", "K2", "N2").setMeasures(newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))),
-      newDoc("P3", "K3", "N3").setMeasures(newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 10_001d))));
-
-    ProjectMeasuresQuery esQuery = new ProjectMeasuresQuery()
-      .addMetricCriterion(new MetricCriteria(NCLOC, Operator.GT, 10_000d));
-    List<String> result = underTest.search(esQuery, new SearchOptions()).getIds();
-
-    assertThat(result).containsExactly("P2", "P3");
+      newDoc("P1", "K1", "N1").setMeasures(newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 30_000d))),
+      newDoc("P2", "K2", "N2").setMeasures(newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 30_001d))),
+      newDoc("P3", "K3", "N3").setMeasures(newArrayList(newMeasure(COVERAGE, 80d), newMeasure(NCLOC, 30_001d))));
+
+    assertThat(underTest.search(new ProjectMeasuresQuery().addMetricCriterion(new MetricCriteria(NCLOC, Operator.GT, 30_000d)),
+      new SearchOptions()).getIds()).containsExactly("P2", "P3");
+    assertThat(underTest.search(new ProjectMeasuresQuery().addMetricCriterion(new MetricCriteria(NCLOC, Operator.GT, 100_000d)),
+      new SearchOptions()).getIds()).isEmpty();
   }
 
   @Test