mkhludnev commented on code in PR #4880:
URL: https://github.com/apache/solr/pull/4880#discussion_r4048376414
##########
solr/core/src/java/org/apache/solr/search/join/ScoreJoinQParserPlugin.java:
##########
@@ -237,6 +256,94 @@ public void visit(QueryVisitor visitor) {
}
}
+ /**
+ * Creates a join query, delegating to {@link
JoinUtil#createJoinQuery(String, boolean, String,
+ * Class, Query, IndexSearcher, ScoreMode)} for a numeric {@code
fromField}/Point {@code toField}
+ * pair, or to {@link JoinUtil#createJoinQuery(String, boolean, String,
Query, IndexSearcher,
+ * ScoreMode)} otherwise.
+ *
+ * @param fromField "foreign key" field name; any field type with a numeric
{@link NumberType}
+ * (not necessarily a Point field type) qualifies, as long as {@code
docValues="true"} is set.
+ * It doesn't need to be {@code indexed}.
+ * @param fromSchema schema holding {@code fromField}, used to detect
numeric doc values
+ * @param toField "primary key" field name
+ * @param toSchema schema holding {@code toField}, used to detect numeric
Point fields
+ * @param fromQuery the query to match documents on the from side
+ * @param fromSearcher the searcher that executed the specified fromQuery
+ * @param scoreMode instructs how scores from the fromQuery are mapped to
the returned query
+ * @return a {@link Query} instance that can be used to join documents based
on the values in the
+ * from and to field
+ */
+ static Query createJoinQuery(
+ String fromField,
+ IndexSchema fromSchema,
+ String toField,
+ IndexSchema toSchema,
+ Query fromQuery,
+ IndexSearcher fromSearcher,
+ ScoreMode scoreMode)
+ throws IOException {
+ final SchemaField fromSchemaField = fromSchema.getFieldOrNull(fromField);
+ final NumberType fromNumberType =
+ fromSchemaField == null ? null :
fromSchemaField.getType().getNumberType();
+ if (fromNumberType != null) {
+ if (!fromSchemaField.hasDocValues()) {
+ throw new SolrException(
+ SolrException.ErrorCode.BAD_REQUEST,
+ "Numeric join 'from' field '"
+ + fromField
+ + "' must have docValues enabled; it doesn't need to be
indexed.");
+ }
+ final SchemaField toSchemaField = toSchema.getFieldOrNull(toField);
Review Comment:
it's handled and reported via exception see lines :301 :311
--
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]