|
@@ -8,6 +8,7 @@
|
|
|
|
|
|
package org.elasticsearch.index.search.stats;
|
|
|
|
|
|
+import org.elasticsearch.Version;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.io.stream.StreamInput;
|
|
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
|
@@ -39,6 +40,7 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
public static final String TERM_VECTORS = "term_vectors"; // possibly refine this one
|
|
|
public static final String POINTS = "points";
|
|
|
public static final String PROXIMITY = "proximity";
|
|
|
+ public static final String KNN_VECTORS = "knn_vectors";
|
|
|
|
|
|
private final Map<String, PerFieldUsageStats> stats;
|
|
|
|
|
@@ -122,11 +124,12 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
PAYLOADS,
|
|
|
TERM_VECTORS, // possibly refine this one
|
|
|
POINTS,
|
|
|
+ KNN_VECTORS,
|
|
|
}
|
|
|
|
|
|
public static class PerFieldUsageStats implements ToXContentFragment, Writeable {
|
|
|
|
|
|
- static final PerFieldUsageStats EMPTY = new PerFieldUsageStats(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
+ static final PerFieldUsageStats EMPTY = new PerFieldUsageStats(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
|
|
|
|
private final long any;
|
|
|
private final long proximity;
|
|
@@ -141,6 +144,7 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
private final long payloads;
|
|
|
private final long termVectors;
|
|
|
private final long points;
|
|
|
+ private final long knnVectors;
|
|
|
|
|
|
public PerFieldUsageStats(
|
|
|
long any,
|
|
@@ -155,7 +159,8 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
long norms,
|
|
|
long payloads,
|
|
|
long termVectors,
|
|
|
- long points
|
|
|
+ long points,
|
|
|
+ long knnVectors
|
|
|
) {
|
|
|
this.any = any;
|
|
|
this.proximity = proximity;
|
|
@@ -170,6 +175,7 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
this.payloads = payloads;
|
|
|
this.termVectors = termVectors;
|
|
|
this.points = points;
|
|
|
+ this.knnVectors = knnVectors;
|
|
|
}
|
|
|
|
|
|
private PerFieldUsageStats add(PerFieldUsageStats other) {
|
|
@@ -186,7 +192,8 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
norms + other.norms,
|
|
|
payloads + other.payloads,
|
|
|
termVectors + other.termVectors,
|
|
|
- points + other.points
|
|
|
+ points + other.points,
|
|
|
+ knnVectors + other.knnVectors
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -204,6 +211,11 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
payloads = in.readVLong();
|
|
|
termVectors = in.readVLong();
|
|
|
points = in.readVLong();
|
|
|
+ if (in.getVersion().onOrAfter(Version.V_8_1_0)) {
|
|
|
+ knnVectors = in.readVLong();
|
|
|
+ } else {
|
|
|
+ knnVectors = 0;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -221,6 +233,9 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
out.writeVLong(payloads);
|
|
|
out.writeVLong(termVectors);
|
|
|
out.writeVLong(points);
|
|
|
+ if (out.getVersion().onOrAfter(Version.V_8_1_0)) {
|
|
|
+ out.writeVLong(knnVectors);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -240,6 +255,7 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
builder.field(POINTS, points);
|
|
|
builder.field(NORMS, norms);
|
|
|
builder.field(TERM_VECTORS, termVectors);
|
|
|
+ builder.field(KNN_VECTORS, knnVectors);
|
|
|
return builder;
|
|
|
}
|
|
|
|
|
@@ -278,6 +294,9 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
if (points > 0L) {
|
|
|
set.add(UsageContext.POINTS);
|
|
|
}
|
|
|
+ if (knnVectors > 0L) {
|
|
|
+ set.add(UsageContext.KNN_VECTORS);
|
|
|
+ }
|
|
|
return set;
|
|
|
}
|
|
|
|
|
@@ -325,6 +344,10 @@ public class FieldUsageStats implements ToXContentObject, Writeable {
|
|
|
return points;
|
|
|
}
|
|
|
|
|
|
+ public long getKnnVectors() {
|
|
|
+ return knnVectors;
|
|
|
+ }
|
|
|
+
|
|
|
public long getProximity() {
|
|
|
return proximity;
|
|
|
}
|