imbajin commented on code in PR #2994:
URL: https://github.com/apache/hugegraph/pull/2994#discussion_r3322976067


##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphIndexTransaction.java:
##########
@@ -756,11 +759,16 @@ private PageIds doIndexQueryOnce(IndexLabel indexLabel,
     @Watched(prefix = "index")
     private Set<MatchedIndex> collectMatchedIndexes(ConditionQuery query) {
         ISchemaTransaction schema = this.params().schemaTransaction();
-        Id label = query.condition(HugeKeys.LABEL);
+        boolean hasLabel = query.containsCondition(HugeKeys.LABEL);
+        Set<Object> labels = query.conditionValues(HugeKeys.LABEL);
 
         List<? extends SchemaLabel> schemaLabels;
-        if (label != null) {
-            // Query has LABEL condition
+        if (hasLabel && labels.isEmpty()) {

Review Comment:
   ‼️ This now treats non-EQ/IN label predicates as an empty label intersection.
   
   `containsCondition(HugeKeys.LABEL)` returns true for any top-level LABEL 
relation, but `conditionValues(HugeKeys.LABEL)` only collects EQ/IN relations. 
For a query such as `has(T.label, P.neq("author")).has("name", ...)`, 
`TraversalUtil` can produce a `Condition.neq(HugeKeys.LABEL, ...)`; `hasLabel` 
becomes true, `labels` is empty, and this branch returns no matched indexes 
immediately.
   
   Before this change, `query.condition(HugeKeys.LABEL)` would not resolve a 
single label for this shape, so `collectMatchedIndexes()` fell back to scanning 
candidate schema labels and let the remaining conditions filter results. With 
the new branch, indexed user-property queries combined with a non-EQ/IN label 
predicate can incorrectly fail with no matched index / no result path.
   
   Please distinguish "LABEL EQ/IN conditions resolved to an empty 
intersection" from "LABEL exists but has no EQ/IN-resolvable value". The latter 
should keep the conservative fallback, or add regression coverage for a label 
`neq` / non-EQ label predicate combined with an indexed user property.



-- 
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]

Reply via email to