summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2020-05-12 15:52:15 +0000
committerGeir Storli <geirst@verizonmedia.com>2020-05-12 15:52:15 +0000
commitfe5a4c73f70cc451f461bc007d1ce7d32481edb2 (patch)
treebd8007d72484c81f11d43ca4a3ec0003f74d0bec /config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java
parent2d5ddf827dcef2af9619f8a9fee148f9edd12b02 (diff)
Support specifying a distance metric for nearest neighbor search when not having a hnsw index.
This also changes the syntax in the sd file to specifying the distance metric in the attribute tag.
Diffstat (limited to 'config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java7
1 files changed, 4 insertions, 3 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java
index 1661a80f238..49d396327bf 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java
@@ -24,7 +24,6 @@ import com.yahoo.document.datatypes.Float16FieldValue;
import com.yahoo.document.datatypes.StringFieldValue;
import com.yahoo.document.datatypes.TensorFieldValue;
import com.yahoo.tensor.TensorType;
-import static com.yahoo.searchdefinition.Index.DistanceMetric;
import java.io.Serializable;
import java.util.LinkedHashSet;
@@ -40,6 +39,8 @@ import java.util.Set;
*/
public final class Attribute implements Cloneable, Serializable {
+ public enum DistanceMetric { EUCLIDEAN, ANGULAR, GEODEGREES }
+
// Remember to change hashCode and equals when you add new fields
private String name;
@@ -228,7 +229,7 @@ public final class Attribute implements Cloneable, Serializable {
public void setUpperBound(long upperBound) { this.upperBound = upperBound; }
public void setDensePostingListThreshold(double threshold) { this.densePostingListThreshold = threshold; }
public void setTensorType(TensorType tensorType) { this.tensorType = Optional.of(tensorType); }
- public void setDistanceMetric(Optional<DistanceMetric> dm) { this.distanceMetric = dm; }
+ public void setDistanceMetric(DistanceMetric metric) { this.distanceMetric = Optional.of(metric); }
public void setHnswIndexParams(HnswIndexParams params) { this.hnswIndexParams = Optional.of(params); }
public String getName() { return name; }
@@ -348,7 +349,7 @@ public final class Attribute implements Cloneable, Serializable {
public int hashCode() {
return Objects.hash(
name, type, collectionType, sorting, isPrefetch(), fastAccess, removeIfZero, createIfNonExistent,
- isPosition, huge, enableBitVectors, enableOnlyBitVector, tensorType, referenceDocumentType, hnswIndexParams);
+ isPosition, huge, enableBitVectors, enableOnlyBitVector, tensorType, referenceDocumentType, distanceMetric, hnswIndexParams);
}
@Override