You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/11/05 22:31:02 UTC

[GitHub] [lucene] sonatype-lift[bot] commented on a change in pull request #429: LUCENE-10223: interval support in standard syntax parser, initial.

sonatype-lift[bot] commented on a change in pull request #429:
URL: https://github.com/apache/lucene/pull/429#discussion_r744008667



##########
File path: lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/builders/MinShouldMatchNodeBuilder.java
##########
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.queryparser.flexible.standard.builders;
+
+import java.util.List;
+import org.apache.lucene.queryparser.flexible.core.builders.QueryBuilder;
+import org.apache.lucene.queryparser.flexible.core.builders.QueryTreeBuilder;
+import org.apache.lucene.queryparser.flexible.core.nodes.QueryNode;
+import org.apache.lucene.queryparser.flexible.standard.nodes.MinShouldMatchNode;
+import org.apache.lucene.search.BooleanQuery;
+import org.apache.lucene.search.Query;
+
+/** Builds a {@link BooleanQuery} from a {@link MinShouldMatchNode}. */
+public class MinShouldMatchNodeBuilder implements QueryBuilder {
+  @Override
+  public Query build(QueryNode queryNode) {
+    MinShouldMatchNode mmNode = (MinShouldMatchNode) queryNode;
+
+    List<QueryNode> children = queryNode.getChildren();
+    if (children.size() != 1) {

Review comment:
       *NULL_DEREFERENCE:*  object `children` last assigned on line 33 could be null and is dereferenced at line 34.
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)

##########
File path: lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/MinShouldMatchNode.java
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.lucene.queryparser.flexible.standard.nodes;
+
+import org.apache.lucene.queryparser.flexible.core.nodes.GroupQueryNode;
+import org.apache.lucene.queryparser.flexible.core.nodes.QueryNodeImpl;
+import org.apache.lucene.queryparser.flexible.core.parser.EscapeQuerySyntax;
+
+/** Node that represents a minimum-should-match restriction on a {@link GroupQueryNode}. */
+public class MinShouldMatchNode extends QueryNodeImpl {
+  public final int minShouldMatch;
+  public final GroupQueryNode groupQueryNode;
+
+  public MinShouldMatchNode(int minShouldMatch, GroupQueryNode groupQueryNode) {
+    this.minShouldMatch = minShouldMatch;
+    this.groupQueryNode = groupQueryNode;
+
+    this.setLeaf(false);
+    this.allocate();

Review comment:
       *NULL_DEREFERENCE:*  object `QueryNodeImpl.clauses` last assigned on line 28 could be null and is dereferenced by call to `allocate()` at line 33.
   (at-me [in a reply](https://help.sonatype.com/lift/talking-to-lift) with `help` or `ignore`)




-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org