Add query traces when contains/matches will likely not work as expected
@@ -18,7 +18,6 @@ import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.yahoo.collections.LazyMap;
import com.yahoo.collections.LazySet;
-import com.yahoo.component.Version;
import com.yahoo.language.Language;
import com.yahoo.language.detect.Detector;
import com.yahoo.language.process.Normalizer;
@@ -1004,7 +1003,7 @@ public class YqlParser implements Parser {
}
private static boolean isIndexOnLeftHandSide(OperatorNode<ExpressionOperator> ast) {
- OperatorNode node = ast.getArgument(0, OperatorNode.class);
+ OperatorNode<?> node = ast.getArgument(0, OperatorNode.class);
return node.getOperator() == ExpressionOperator.READ_FIELD || node.getOperator() == ExpressionOperator.PROPREF;
}
@@ -1080,13 +1079,20 @@ public class YqlParser implements Parser {
@NonNull
private Item buildTermSearch(OperatorNode<ExpressionOperator> ast) {
assertHasOperator(ast, ExpressionOperator.CONTAINS);
- return instantiateLeafItem(getIndex(ast.<OperatorNode<ExpressionOperator>> getArgument(0)), ast.<OperatorNode<ExpressionOperator>> getArgument(1));
+ String field = getIndex(ast.<OperatorNode<ExpressionOperator>>getArgument(0));
+ if (userQuery != null && indexFactsSession.getIndex(field).isAttribute()) {
+ userQuery.trace("Field '" + field + "' is an attribute, 'contains' will only match exactly", 1);
+ }
+ return instantiateLeafItem(field, ast.<OperatorNode<ExpressionOperator>> getArgument(1));
}
@NonNull
private Item buildRegExpSearch(OperatorNode<ExpressionOperator> ast) {
assertHasOperator(ast, ExpressionOperator.MATCHES);
String field = getIndex(ast.<OperatorNode<ExpressionOperator>>getArgument(0));
+ if (userQuery != null && !indexFactsSession.getIndex(field).isAttribute()) {
+ userQuery.trace("Field '" + field + "' is indexed, non-literal regular expressions will not be matched", 1);
+ }
OperatorNode<ExpressionOperator> ast1 = ast.<OperatorNode<ExpressionOperator>> getArgument(1);
String wordData = getStringContents(ast1);
RegExpItem regExp = new RegExpItem(field, true, wordData);
