mirror of
https://github.com/apache/lucene.git
synced 2025-02-10 03:55:46 +00:00
SOLR-13720: BlockJoinParentQParser.getCachedFilter made public
This commit is contained in:
parent
12715da544
commit
c857c1da3d
@ -89,6 +89,9 @@ Improvements
|
||||
|
||||
* SOLR-13542: Code cleanup - Avoid using stream filter count where possible (Koen De Groote via Tomás Fernández Löbbe)
|
||||
|
||||
* SOLR-13720: BlockJoinParentQParser.getCachedFilter()made public for accessing from QParser plugins
|
||||
(Stanislav Livotov via Mikhail Khludnev)
|
||||
|
||||
Bug Fixes
|
||||
----------------------
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class BlockJoinChildQParser extends BlockJoinParentQParser {
|
||||
|
||||
@Override
|
||||
protected Query createQuery(Query parentListQuery, Query query, String scoreMode) {
|
||||
return new ToChildBlockJoinQuery(query, getFilter(parentListQuery).filter);
|
||||
return new ToChildBlockJoinQuery(query, getFilter(parentListQuery).getFilter());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +84,7 @@ public class BlockJoinParentQParser extends FiltersQParser {
|
||||
return getCachedFilter(req, parentList);
|
||||
}
|
||||
|
||||
static BitDocIdSetFilterWrapper getCachedFilter(final SolrQueryRequest request, Query parentList) {
|
||||
public static BitDocIdSetFilterWrapper getCachedFilter(final SolrQueryRequest request, Query parentList) {
|
||||
SolrCache parentCache = request.getSearcher().getCache(CACHE_NAME);
|
||||
// lazily retrieve from solr cache
|
||||
Filter filter = null;
|
||||
@ -122,9 +122,9 @@ public class BlockJoinParentQParser extends FiltersQParser {
|
||||
}
|
||||
|
||||
// We need this wrapper since BitDocIdSetFilter does not extend Filter
|
||||
static class BitDocIdSetFilterWrapper extends Filter {
|
||||
public static class BitDocIdSetFilterWrapper extends Filter {
|
||||
|
||||
final BitSetProducer filter;
|
||||
private final BitSetProducer filter;
|
||||
|
||||
BitDocIdSetFilterWrapper(BitSetProducer filter) {
|
||||
this.filter = filter;
|
||||
@ -139,6 +139,10 @@ public class BlockJoinParentQParser extends FiltersQParser {
|
||||
return BitsFilteredDocIdSet.wrap(new BitDocIdSet(set), acceptDocs);
|
||||
}
|
||||
|
||||
public BitSetProducer getFilter() {
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(String field) {
|
||||
return getClass().getSimpleName() + "(" + filter + ")";
|
||||
@ -147,14 +151,13 @@ public class BlockJoinParentQParser extends FiltersQParser {
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return sameClassAs(other) &&
|
||||
Objects.equals(filter, getClass().cast(other).filter);
|
||||
Objects.equals(filter, getClass().cast(other).getFilter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return classHash() + filter.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -177,8 +177,8 @@ public class ChildFieldValueSourceParser extends ValueSourceParser {
|
||||
}
|
||||
bjQ = (AllParentsAware) query;
|
||||
|
||||
parentFilter = BlockJoinParentQParser.getCachedFilter(fp.getReq(), bjQ.getParentQuery()).filter;
|
||||
childFilter = BlockJoinParentQParser.getCachedFilter(fp.getReq(), bjQ.getChildQuery()).filter;
|
||||
parentFilter = BlockJoinParentQParser.getCachedFilter(fp.getReq(), bjQ.getParentQuery()).getFilter();
|
||||
childFilter = BlockJoinParentQParser.getCachedFilter(fp.getReq(), bjQ.getChildQuery()).getFilter();
|
||||
|
||||
if (sortFieldName==null || sortFieldName.equals("")) {
|
||||
throw new SyntaxError ("field is omitted in "+fp.getString());
|
||||
|
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.another;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.WildcardQuery;
|
||||
import org.apache.lucene.search.join.ScoreMode;
|
||||
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
import org.apache.solr.search.join.BlockJoinParentQParser;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import static org.apache.solr.search.join.BJQParserTest.createIndex;
|
||||
|
||||
public class BJQFilterAccessibleTest extends SolrTestCaseJ4 {
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
initCore("solrconfig.xml", "schema15.xml");
|
||||
createIndex();
|
||||
}
|
||||
|
||||
public void testAbilityToCreateBJQfromAnotherPackage() throws IOException {
|
||||
try (SolrQueryRequest req = lrf.makeRequest()) {
|
||||
TermQuery childQuery = new TermQuery(new Term("child_s", "l"));
|
||||
Query parentQuery = new WildcardQuery(new Term("parent_s", "*"));
|
||||
ToParentBlockJoinQuery tpbjq = new ToParentBlockJoinQuery(childQuery, BlockJoinParentQParser.getCachedFilter(req,parentQuery).getFilter(), ScoreMode.Max);
|
||||
Assert.assertEquals(6, req.getSearcher().search(tpbjq,10).totalHits.value);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user