lance-format / lance-format/lance
feat(index): support flattened JSON sub-doc indexing
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 7.1k
- Forks
- 852
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 272
Description
Parent: #4516
Draft PR: #7377
Motivation
Lance JSON inverted indexes should preserve array/object structure so path queries over arrays of objects can distinguish exact positions, wildcards, and nested-object constraints.
Tantivy documents a known flaw of bag-of-terms JSON array indexing: a query like cart.product_type:sneakers AND cart.attributes.color:red can match even when sneakers and red live in different objects in the same array. Lance's current single-token-stream JSON index has the same class of problem.
Proposal
Introduce FlattenedSubDocs mode for new JSON inverted indexes. A JSON row can flatten into multiple internal sub-documents, and matches are mapped back to the original Lance row id. This lets related JSON path constraints match inside the same flattened array element before row-id remapping.
Also add disable_cross_array_unnest=false by default, with an opt-in memory-safety tradeoff for documents with many sibling arrays, following Pinot's DisableCrossArrayUnnest behavior.
Expected behavior
- Existing JSON indexes remain readable using
SingleDocumentmode. - New JSON indexes use
FlattenedSubDocsmode. - Positional and wildcard queries can return different row sets, for example
foo[0].bar[0],str,yvsfoo[0].bar[*],str,y. - Nested-object constraints should be expressed as one JSON
MatchQuerywith semicolon-separated triplets plusOperator::And, so matching happens at flattened sub-doc granularity. - Separate
BooleanQuery.mustchild queries remain row-level composition and are not the query shape for nested-object semantics.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the parent issue #4516 and the draft PR #7377, then inspect the existing JSON inverted-index behavior described here. Done means new indexes use FlattenedSubDocs, existing indexes remain readable, positional and wildcard queries return the expected row sets, and nested-object constraints match within the same flattened sub-document.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- databases, search
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100