You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2021/10/29 18:18:04 UTC

[GitHub] [solr] madrob commented on a change in pull request #338: @sayandigital SOLR-13182 - NullPointerException

madrob commented on a change in pull request #338:
URL: https://github.com/apache/solr/pull/338#discussion_r739445201



##########
File path: solr/core/src/java/org/apache/solr/search/join/BlockJoinChildQParser.java
##########
@@ -44,10 +45,8 @@ protected String getParentFilterLocalParamName() {
   @Override
   protected Query noClausesQuery() throws SyntaxError {
     final Query parents = parseParentFilter();
-    final BooleanQuery notParents = new BooleanQuery.Builder()
-        .add(new MatchAllDocsQuery(), Occur.MUST)
-        .add(parents, Occur.MUST_NOT)
-      .build();
-    return new BitSetProducerQuery(getBitSetProducer(notParents));
+    final BooleanQuery.Builder notParentsBuilder = new BooleanQuery.Builder().add(new MatchAllDocsQuery(), Occur.MUST);
+    final BitSetProducerQuery notParentsQuery=(parents!=null)?  new BitSetProducerQuery(getBitSetProducer(notParentsBuilder.add(parents, Occur.MUST_NOT).build())): new BitSetProducerQuery(getBitSetProducer(notParentsBuilder.build()));
+    return notParentsQuery;

Review comment:
       This is very hard to read, can you add some whitespace here or possibly switch to using a proper if statement instead of ternary conditional.

##########
File path: solr/core/src/test/org/apache/solr/search/join/BlockJoinChildQueryParserTest.java
##########
@@ -0,0 +1,45 @@
+/*
+ * 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.solr.search.join;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.io.IOException;
+
+public class BlockJoinChildQueryParserTest extends SolrTestCaseJ4 {
+
+    @BeforeClass
+    public static void beforeClass() throws Exception {
+        initCore("solrconfig.xml", "schema.xml");
+        createIndex();
+    }
+
+    public static void createIndex() throws IOException, Exception {
+        assertU(adoc("id", "1", "name", "45", "directed_by_s", "Lennon"));
+        assertU(adoc("id", "2", "name", "42", "directed_by_s", "Block"));
+        assertU(commit());
+        assertQ(req("q", "*:*"), "//*[@numFound='" + 2 + "']");
+    }
+
+    @Test
+    public void testChildrenParserEmpty() {
+        assertQ(
+                req("q", "{!child q={}"), "//*[@numFound='2']");

Review comment:
       Could this be in `BJQParserTest` instead of creating a new class for a single assertion?




-- 
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@solr.apache.org

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



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