"Group by" like milvus/zilliz has

When retrieving chunks, often the goal is to return the top e.g. 10 documents. If those documents have multiple chunks each, topK of 10 isn’t enough, we need to overshoot and/or recursively attempt to get more results to get 10 documents.

In Milvus/Zilliz we can use Group By meta value https://milvus.io/docs/grouping-search.md - so in the Milvus Provider in the Drupal community I co-maintain, it results in us grouping by the entity ID as shown in MilvusV2.php line ~360 (sorry cannot link to it, not allowed)

However in the Pinecone Provider I also co-maintain, we cannot do this, so we sometimes have to query a lot more when a user requests top 10 documents rather than top 10 chunks, essentially keep trying until we have 10 unique documents. This is a waste of resource and makes Pinecone slower in comparison for such searches.

As background each record Drupal indexes contains multiple meta data fields that the user can configure BUT always contains:

  • drupal_entity_id = entity ID from drupal → this is the same across all chunks for a document
  • drupal_long_id = entity ID from drupal + chunk ID from splitting long content → this is unique per chunk

We want to Group By drupal_entity_id to improve the retrieval time.