benwtrent commented on issue #13921:
URL: https://github.com/apache/lucene/issues/13921#issuecomment-2416554406

   @hanqiushi you don't need to do anything special. Since its a format, you 
only have to query the index. 
   
   So, once you have indexed a bunch of 
[KnnFloatVectorField](https://lucene.apache.org/core/9_12_0/core/org/apache/lucene/document/KnnFloatVectorField.html),
 you can just search them with a 
[KnnFloatVectorQuery](https://lucene.apache.org/core/9_12_0/core/org/apache/lucene/search/KnnFloatVectorQuery.html).
 
   
   Example:
   
   ```
   try (IndexReader reader = DirectoryReader.open(dir)) {
     IndexSearcher searcher = new IndexSearcher(reader);
      TopDocs topDocs = searcher.search(new KnnFloatVectorQuery(
       KNN_VECTOR_FIELD, // the field name.
       queryVector, // the float query vector, dims must be the same as the 
indexed fields
       k), // the `k` to search for, could be considered efSearch
       k); // how many docs to return
   ```
   
   Some other tips:
   
    - Use `confidence_interval=0` in the format, this greatly improves `int4` 
quality.
    - Pass `compress=true` as well or you will not gain the memory advantages. 
   SEE: 
https://lucene.apache.org/core/9_12_0/core/org/apache/lucene/codecs/lucene99/Lucene99HnswScalarQuantizedVectorsFormat.html#%3Cinit%3E(int,int,int,int,boolean,java.lang.Float,java.util.concurrent.ExecutorService)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to