Răsfoiți Sursa

add ANNOY index

Signed-off-by: youny626 <zzhu@fandm.edu>
youny626 5 ani în urmă
părinte
comite
28c2e5a1bb

+ 7 - 3
src/main/java/io/milvus/client/Index.java

@@ -76,11 +76,12 @@ public class Index {
     }
 
     /**
-     * Optional. Default to empty <code>String</code>.
+     * Optional. Default to empty <code>String</code>. Index parameters are different for different
+     * index types. Refer to <a
+     * href="https://milvus.io/docs/v0.7.0/guides/milvus_operation.md">https://milvus.io/docs/v0.7.0/guides/milvus_operation.md</a>
+     * for more information.
      *
      * <pre>
-     * For different index type, index parameter is different accordingly, for example:
-     *
      * FLAT/IVFLAT/SQ8: {"nlist": 16384}
      * nlist range:[1, 999999]
      *
@@ -97,6 +98,9 @@ public class Index {
      * HNSW: {"M": 16, "efConstruction": 500}
      * M range:[5, 48]
      * efConstruction range:[100, 500]
+     *
+     * ANNOY: {"n_trees": 4}
+     * n_trees range: [1, 16384)
      * </pre>
      *
      * @param paramsInJson extra parameters in JSON format

+ 4 - 28
src/main/java/io/milvus/client/IndexType.java

@@ -23,34 +23,9 @@ import java.util.Arrays;
 import java.util.Optional;
 
 /**
- * Represents different types of indexing method to query the collection:
- *
- * <pre>
- *
- * 1. FLAT - Provides 100% accuracy for recalls. However, performance might be downgraded due to huge computation effort;
- *
- * 2. IVFLAT - K-means based similarity search which is balanced between accuracy and performance;
- *
- * 3. IVF_SQ8 - Vector indexing that adopts a scalar quantization strategy that significantly reduces the size of a
- * vector (by about 3/4), thus improving the overall throughput of vector processing;
- *
- * 4. RNSG - NSG (Navigating Spreading-out Graph) is a graph-base search algorithm that a) lowers the average
- * out-degree of the graph for fast traversal; b) shortens the search path; c) reduces the index
- * size; d) lowers the indexing complexity. Extensive tests show that NSG can achieve very high
- * search performance at high precision, and needs much less memory. Compared to non-graph-based
- * algorithms, it is faster to achieve the same search precision.
- *
- * 5. IVF_SQ8_H - An enhanced index algorithm of IVF_SQ8. It supports hybrid computation on both CPU and GPU,
- * which significantly improves the search performance. To use this index type, make sure both cpu and gpu are added as
- * resources for search usage in the Milvus configuration file.
- *
- * 6. IVF_PQ - Indexing method built based on product quantization. The input vectors are split into distinct sub-vectors
- * which are then quantized separately. Vector size can be reduced to 1/8 or 1/16 of the original size.
- * If you choose this index, note that there is an inevicollection trade-off between memory and search accuracy.
- *
- * 7. HNSW - Hierarchical Navigable Small World graphs
- *
- * </pre>
+ * Represents different types of indexing method to query the collection. Refer to <a
+ * href="https://milvus.io/docs/v0.7.0/guides/index.md">https://milvus.io/docs/v0.7.0/guides/index.md</a>
+ * for more information.
  */
 public enum IndexType {
   INVALID(0),
@@ -61,6 +36,7 @@ public enum IndexType {
   IVF_SQ8_H(5),
   IVF_PQ(6),
   HNSW(11),
+  ANNOY(12),
 
   UNKNOWN(-1);
 

+ 7 - 3
src/main/java/io/milvus/client/MetricType.java

@@ -22,7 +22,11 @@ package io.milvus.client;
 import java.util.Arrays;
 import java.util.Optional;
 
-/** Represents available metric types */
+/**
+ * Represents available metric types. Refer to <a
+ * href="https://milvus.io/docs/v0.7.0/guides/metric.md">https://milvus.io/docs/v0.7.0/guides/metric.md</a>
+ * for more information.
+ */
 public enum MetricType {
   INVALID(0),
   /** Euclidean distance. For float vectors only */
@@ -35,9 +39,9 @@ public enum MetricType {
   JACCARD(4),
   /** Tanimoto distance. For binary vectors only */
   TANIMOTO(5),
-  /** Substructure: D(a, b) = 1 - N(a&b) / N(b). For binary vectors only */
+  /** Substructure. For binary vectors only */
   SUBSTRUCTURE(6),
-  /** Superstructure: D(a, b) = 1 - N(a&b) / N(a). For binary vectors only */
+  /** Superstructure. For binary vectors only */
   SUPERSTRUCTURE(7),
 
   UNKNOWN(-1);

+ 7 - 3
src/main/java/io/milvus/client/SearchParam.java

@@ -136,11 +136,12 @@ public class SearchParam {
     }
 
     /**
-     * Optional. Default to empty <code>String</code>.
+     * Optional. Default to empty <code>String</code>. Search parameters are different for different
+     * index types. Refer to <a
+     * href="https://milvus.io/docs/v0.7.0/guides/milvus_operation.md">https://milvus.io/docs/v0.7.0/guides/milvus_operation.md</a>
+     * for more information.
      *
      * <pre>
-     *   For different index type, search parameter is different accordingly, for example:
-     *
      *   FLAT/IVFLAT/SQ8/IVFPQ: {"nprobe": 32}
      *   nprobe range:[1,999999]
      *
@@ -149,6 +150,9 @@ public class SearchParam {
      *
      *   HNSW: {"ef": 64}
      *   ef range:[topk, 4096]
+     *
+     *   ANNOY: {search_k", 0.05 * totalDataCount}
+     *   search_k range: none
      * </pre>
      *
      * @param paramsInJson extra parameters in JSON format