1313#define INDEX_NODE_H
1414
1515#include < functional>
16+ #include < memory>
1617#include < mutex>
1718#include < queue>
1819#include < utility>
@@ -46,13 +47,11 @@ struct OpContext;
4647class ThreadPool ;
4748#endif
4849
49- namespace faiss {
50- class IndexFlat ;
51- } // namespace faiss
52-
5350namespace knowhere {
5451
5552class Interrupt ;
53+ class EmbListRawStorage ;
54+ struct EmbListSeparateAnnIndexHolder ;
5655
5756class IndexNode : public Object {
5857 public:
@@ -318,6 +317,23 @@ class IndexNode : public Object {
318317 virtual int64_t
319318 Count () const = 0 ;
320319
320+ // Returns the ANN index that currently serves vector-level metadata/search.
321+ // EmbList strategies normally use this node itself, but a strategy may build
322+ // a child ANN index when its ANN representation has a different data type.
323+ virtual IndexNode*
324+ AnnIndexNode ();
325+
326+ virtual const IndexNode*
327+ AnnIndexNode () const ;
328+
329+ virtual int64_t
330+ CountForSearchBitset () const {
331+ if (emb_list_strategy_ != nullptr && emb_list_strategy_->GetDocCount () >= 0 ) {
332+ return emb_list_strategy_->GetDocCount ();
333+ }
334+ return Count ();
335+ }
336+
321337 virtual std::string
322338 Type () const = 0 ;
323339
@@ -496,6 +512,10 @@ class IndexNode : public Object {
496512 SearchEmbListIfNeed (const DataSetPtr dataset, std::unique_ptr<Config> config, const BitsetView& bitset,
497513 milvus::OpContext* op_context = nullptr ) const ;
498514
515+ virtual expected<DataSetPtr>
516+ SearchEmbListAnnIndex (const DataSetPtr dataset, std::unique_ptr<Config> config, const BitsetView& bitset,
517+ milvus::OpContext* op_context = nullptr ) const ;
518+
499519 /* *
500520 * @brief Returns the code size (in bytes) of a single query vector, which varies depending on the data type (e.g.,
501521 * fp32, bf16, etc).
@@ -619,10 +639,10 @@ class IndexNode : public Object {
619639
620640 protected:
621641 /* *
622- * @brief Compute distances using emb_list_raw_index_ ( raw vector storage) .
642+ * @brief Compute distances using emb_list raw vector storage.
623643 *
624- * Used by CalcDistByIDs implementations when emb_list_raw_index_ is present
625- * (MUVERA/LEMUR strategies). The raw index stores original vectors indexed by
644+ * Used by CalcDistByIDs implementations when emb_list raw storage is present
645+ * (MUVERA/LEMUR strategies). The raw storage keeps original vectors indexed by
626646 * global vector IDs, so no ID translation is needed.
627647 *
628648 * @param pool Thread pool for parallel computation
@@ -637,14 +657,14 @@ class IndexNode : public Object {
637657 std::string el_metric_type_;
638658 EmbListStrategyPtr emb_list_strategy_; // emb_list encoding strategy (tokenann/muvera)
639659 // Raw vector storage for EmbList strategies (MUVERA/LEMUR) that encode documents
640- // into different representations for ANN search. Since the base index holds encoded
641- // vectors (not raw), this IndexFlat stores original vectors for exact distance
642- // computation during MaxSim reranking.
643- // Baseline type so that the same shared_ptr can hold either the knowhere
644- // Jaccard-aware IndexFlat subclass (fresh build path, if ever needed) or
645- // a plain ::faiss::IndexFlat{,IP,L2} restored by the deserialization
646- // factory in cppcontrib/knowhere/impl/index_read.cpp.
647- std::shared_ptr<::faiss::IndexFlat> emb_list_raw_index_ ;
660+ // into different representations for ANN search. The ANN index may be this node's
661+ // BaseIndex or a SeparateIndex, so raw storage keeps the original vectors available
662+ // for exact distance computation during MaxSim reranking.
663+ std:: shared_ptr<EmbListRawStorage> emb_list_raw_storage_;
664+ // Optional child ANN index used when a strategy's ANN representation has a different
665+ // data type from this IndexNode, for example binary LEMUR producing fp32 vectors.
666+ std::shared_ptr<EmbListSeparateAnnIndexHolder> emb_list_separate_ann_index_;
667+ std::string emb_list_raw_metric_type_ ;
648668
649669#if defined(NOT_COMPILE_FOR_SWIG) && !defined(KNOWHERE_WITH_LIGHT)
650670 struct PrometheusMetrics {
0 commit comments