Repository navigation
Conversation
batrived
marked this pull request as ready for review
November 19, 2026 21:29
batrived
force-pushed
the
feat/4923-mixed-index-sort-key-field
branch
from
November 19, 2026 22:57
cbc6b5a to
a44360b
Compare
…lookup (JanusGraph#4923) An edge of a MULTI label with a sort key is stored under the column [type+dir][sortKey][adjacent][relationId]. Its id has no sort-key values, so every edge a mixed index returned for such a label was resolved by reading every edge of that label on its vertex. With the new option index.[X].store-edge-sort-key (default false), each such edge document in an Elasticsearch index carries its encoded sort key in a retrieval-only field, jg_system____sortkey. Queries return it with each hit, and the edge is read with a single column lookup. A hit whose sort key no longer matches its edge falls back to the scan, so a stale value never hides an edge. Edge ids, document ids and the composite index format are unchanged. - IndexProvider.queryHits (default methods) returns hits with the field; IndexFeatures.supportsEdgeSortKeyField gates it. Lucene, Solr and third-party providers report no support, so the option is ignored for them and their queries behave as before. - Elasticsearch maps the field as a non-indexed keyword and reads it from _source. Where an external mapping cannot hold the field and may not be updated, the store's edge documents are written without it, with one warning, instead of failing the index commit. - EdgeIdWithSortKey equals only another EdgeIdWithSortKey of the same id; SubqueryIterator unwraps before testing membership. - EdgeSerializer.getQuery no longer moves the sort-key end past the adjacent vertex id, which made fully constrained queries on DESC labels miss the column. - A mixed index field can no longer be named jg_system____sortkey. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Balmukund Trivedi <btrivedipublic@gmail.com>
batrived
force-pushed
the
feat/4923-mixed-index-sort-key-field
branch
from
November 19, 2026 23:35
a44360b to
96ade82
Compare
Contributor
Author
|
@porunov Please take a look. Thanks! |
This branch has not been deployed
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.
Fixes #4923.
For a
MULTIlabel with a sort key, the edge column is[type+dir][sortKey][adjacent][relationId], butRelationIdentifierhas no sort-key values. So every edge a mixed index returns for such a label is resolved by reading every edge of that label on its vertex: N hits x O(degree).Change
index.[X].store-edge-sort-key(MASKABLE, defaultfalse; nothing changes unless enabled). With it on, each document of such an edge carries its encoded sort key in a retrieval-only field,jg_system____sortkey(stored, not searchable). The name follows the prefix convention of internal index fields so that it can't collide with a field of an existing index. Queries return it with each hit, and the edge is read with a single column lookup.IndexProvider.queryHits(...)returningIndexHit(id + nullable sort key), gated byIndexFeatures.supportsEdgeSortKeyField(). Third-party providers keep working, without the faster lookup.IndexFeatures.supportsEdgeSortKeyField()without core changes.keywordwithindex: falseanddoc_values: false, and read via_sourcefiltering.allow-mapping-updatepermits, and used unmapped under"dynamic": false. A mapping that can't hold the field (strict without it, dynamic without update permission, or mapped as something other thankeyword/text) has the store's edge documents written without it, with one warning, instead of failing the index commit after the storage commit. Queries of such a store don't request_source.clearStoreforgets the decision for the store.FORKlabels, constrained multiplicities and sort keys over 256 encoded bytes carry no field.jg_system____sortkey.EdgeIdWithSortKey(the id + sort key that travels with a hit) equals only another wrapper of the same id; the index intersection unwraps before testing membership.EdgeSerializer.getQueryreassignedkeyEndPosper implicit key, so with sort key + adjacent + relation id constrained on aDESClabel the slice never matched. Happy to split this into its own PR.Tests
JanusGraphIndexTest: with 100–200 edges of one label on a vertex, a mixed index hit reads 1 edgestore entry with the option on and ≥ the label's degree with it off. Covered for ASC, DESC, a two-key sort key, a sort-key change, a stale sort key, REINDEX backfill, a composite + mixed edge query,FORKlabels and the reserved field name.IndexProviderTest: the field is returned per hit after add, update, remove and restore, for plain and raw queries, and is not searchable. Runs for every provider that supports it.ElasticsearchConfigTest: under a strict external mapping and a dynamic one without update permission, the edge document is written without the field and its hit carries no sort key.IndexSerializerTest,EdgeSerializerTest(DESC query; fails without the fix),EdgeIdWithSortKeyTest, and ES unit tests for the request body and hit parsing.ElasticsearchIndexTest,ElasticsearchConfigTest,ElasticsearchJanusGraphIndexTest; no Docker), which are the only end-to-end coverage now that the feature is Elasticsearch-only, so this is a draft until CI has run them.For all changes:
master)?For code changes:
For documentation related changes:
🤖 Generated with Claude Code