contrueCT commented on code in PR #3243:
URL: https://github.com/apache/hugegraph/pull/3243#discussion_r4124273574
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java:
##########
@@ -805,9 +814,49 @@ private Set<MatchedIndex>
collectMatchedIndexes(ConditionQuery query) {
matchedIndexes.add(index);
}
}
+ if (requireCompleteCoverage && !matchedIndexes.isEmpty()) {
+ this.checkIndexCoverage(query, schemaLabels, matchedIndexes);
+ }
return matchedIndexes;
}
+ private void checkIndexCoverage(ConditionQuery query,
+ List<? extends SchemaLabel> labels,
+ Set<MatchedIndex> indexes) {
+ // Check at execution, before creating any lazy index iterator. Cleanup
+ // callers only need matching indexes and must not require full
coverage.
+ Set<Id> requiredProperties = query.userpropKeys();
+ if (this.graph().readMode().showOlap()) {
+ // OLAP properties are shared rather than declared on every label.
+ requiredProperties.removeIf(id ->
this.graph().propertyKey(id).olap());
+ }
+ Set<Id> covered = new HashSet<>();
+ for (MatchedIndex index : indexes) {
+ covered.add(index.schemaLabel().id());
+ }
+ for (SchemaLabel label : labels) {
+ if (covered.contains(label.id()) ||
+ !label.properties().containsAll(requiredProperties)) {
+ continue;
+ }
+ if (label instanceof EdgeLabel) {
+ EdgeLabel edgeLabel = (EdgeLabel) label;
+ // Base labels have no direct edges; their property indexes
+ // include edges of their sub-labels (see updateEdgeIndex()).
+ if (edgeLabel.isFather() ||
+ edgeLabel.hasFather() &&
covered.contains(edgeLabel.fatherId())) {
+ continue;
+ }
+ }
+ // Authorization filters elements after the backend query. Do not
+ // disclose an implicitly discovered schema label in this error.
+ throw new NoIndexException("Incomplete index coverage for
properties %s; " +
Review Comment:
I added the user-facing guidance in apache/hugegraph-doc#503, alongside the
existing `properties` parameter descriptions in the English and Chinese Vertex
and Edge REST API pages. It explains unlabeled candidate labels (including
empty labels), no/partial/complete index coverage, and the `label` or
compatible-index remedies. The Edge page also distinguishes `vertex_id`-bounded
adjacency filtering from a global edge search. I linked the docs PR in this PR
description; it should merge with or after #3243. The design Gist remains for
implementation details, with no explanatory document added to the code
repository.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]