Repository navigation
feat(index): tokenize JSON arrays into sub-documents - #7377
Conversation
|
Important This PR touches the Lance format specification. Substantive changes to the format specification — the If this is a meaningful format change:
|
westonpace
left a comment
There was a problem hiding this comment.
This seems like a useful addition to the JSON full text search. I think disable_cross_array_unnest is going to be pretty technical for the user to judge. It might be nice to have some guardrails. For example, if a single document generates more than X subdocs (or maybe more than X subdocs per byte of the original doc) we could log a warning like "more than X subdocuments generated for a single document, if you have sibling arrays you may need to disable cross array unnesting to avoid a combinatorial explosion". Or we could have a "max_subdocs_per_doc" variable that, if exceeded, would fail the index build.
In the other direction we could potentially add some kind of conservative one-time warning. If the user disabled cross array unnesting and then queried the index using multiple constraints. We wouldn't easily know they were multiple sibling array constraints but the warning could be something like "you are querying a JSON text index with multiple constraints and the index was built with cross array unnesting disabled. If those constraints are on two different sibling arrays you may get false negatives. To disable this warning set the environment variable ..."
Ideally we will want some examples added to the docs as well. We could probably expand https://lance.org/guide/json/#full-text-search-on-json-documents
jja725
left a comment
There was a problem hiding this comment.
Thanks for this great contribution! this would help a lot with FTS
|
@jja725 @westonpace Sorry for the late reply. Somehow I miss the email notification about your folks' feedback during vacation. I will work on the improvement this week. Appreciate you folks compliment on this idea. In terms of adding the parameter "max_sub_docs_per_row", do you folks prefer failing the whole indexing process OR logging an error but keep the already flattened docs? |
Either approach is fine. Failing the entire operation is safest but could be quite annoying if there is only one bad row. In vector indexing, if we encounter NaN / NULL embeddings, we just exclude that row from the index (so it will never appear in search) so there is some precedence for just skipping too. |
|
Following up on
Default proposal: unset I'll wait for feedback from @westonpace and @jja725 before implementing this. |
4fde428 to
3b2df6c
Compare
3b2df6c to
243b5e1
Compare
75144ce to
ae2c627
Compare
255666a to
9aa0019
Compare
9aa0019 to
1a475d5
Compare
|
I split the original big PRs into multiple incremental ones. I don't have the access to create branches on the upstream repo to leverage the Stacking PRs. Check the roadmap: #7445 |
|
Important Format specification voteThis PR modifies the Lance format specification, so it requires 3 binding +1 votes from PMC members (excluding the proposer), at least one of them on the latest commit, and a minimum 72-hour voting period, weekends excluded, before it can merge. Vote by approving this PR (+1) or requesting changes (−1, a veto). See the voting process. Approvals carry over across pushes, so a rebase or a typo fix does not send everyone back to re-vote. Whoever approves the latest commit is vouching that nothing substantive has changed since the earlier approvals; if something has, ask for fresh votes. Status: ❌ Blocked — 0 of 3 required approvals
Updated automatically by the format-spec vote gate, which re-checks every 15 minutes — just voted? Re-check now (press Run workflow; leave the input blank to re-check every open format PR). A PMC member may apply the |
…20261101 # Conflicts: # rust/lance-index/src/scalar/inverted/tokenizer/document_tokenizer.rs
Reject flattened mode through the legacy single-document stream entry point, validate exact array indexes, and keep the test-only sibling policy setter out of production builds. Add query-path and empty/NULL coverage.
There was a problem hiding this comment.
Existing index construction still uses SingleDocument, so the staged tokenizer foundation can land without activating new indexing or search semantics.
The sibling-array expansion risk remains: opt-in flattening can materialize an unbounded Cartesian product. This is non-blocking while the mode stays outside normal index creation; the planned per-row cap should land before default activation.
Xuanwo
left a comment
There was a problem hiding this comment.
Approving the staged JSON tokenizer foundation. The default index path remains SingleDocument, flattened mode cannot be consumed through the legacy single-document stream API, and exact array indexes are validated with focused regression coverage. All applicable checks pass on this head. The sibling-array expansion cap remains required before activation, as documented in #7445.
JSON arrays need element boundaries in the inverted index: otherwise a query can combine values from different array elements. This adds a JSON tokenizer mode that emits one or more sub-documents per row and turns bracketed paths into position constraints. Existing indices continue to use the single-document mode.
This is the tokenizer foundation. The later PRs connect it to index creation and search. The design, query examples, and implementation order are tracked in #7445; index settings are next.
Validation: Rust formatting and
cargo check -p lance-index --testspassed.