(feat) Add field collapse support for search result deduplication with inner_hits support#2251
Open
ajroetker wants to merge 3 commits intoblevesearch:masterfrom
Open
Conversation
This implements Elasticsearch-style field collapsing to deduplicate search results based on a field value. This is useful for scenarios like document chunking where multiple indexed chunks should be represented by only the top-scoring chunk per document. - Collapse results by any stored field with doc values - Returns highest-scoring document per unique field value - Null/missing values grouped together
…pport Enables document chunking workflows where each document is split into multiple searchable chunks, but you want to deduplicate results while still showing multiple relevant chunks per document. - Returns one representative per unique field value (e.g., document_id) - InnerHits retrieve additional documents from each group with independent sorting (e.g., rank groups by relevance, show most recent chunks within each group) - Multiple named inner_hits configurations per collapse - Pagination (from/size) within groups - Second-level collapse for hierarchical grouping Example use cases: - RAG systems: Return top documents, show multiple relevant chunks per document - E-commerce: Group product variants, show different colors/sizes - Search results: Deduplicate by domain, show multiple pages per site Implements hierarchical response structure matching Elasticsearch's collapse feature with full inner_hits support.
…lapsing Resolved conflict in search/collector/topn.go: - Updated to use upstream's HybridMergeCallbackFn instead of ScoreExplCorrectionCallbackFunc - Added nestedStore field from upstream - Preserved collapse support with inner_hits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements Elasticsearch-style field collapsing to deduplicate search results based on a field value. This is useful for scenarios like document chunking where multiple indexed chunks should be represented by only the top-scoring chunk per document.