Search in sources :

Example 1 with AllParentsAware

use of org.apache.solr.search.join.BlockJoinParentQParser.AllParentsAware in project lucene-solr by apache.

the class ChildFieldValueSourceParser method parse.

@Override
public ValueSource parse(FunctionQParser fp) throws SyntaxError {
    final String sortFieldName = fp.parseArg();
    final Query query;
    if (fp.hasMoreArguments()) {
        query = fp.parseNestedQuery();
    } else {
        query = fp.subQuery(fp.getParam(CommonParams.Q), BlockJoinParentQParserPlugin.NAME).getQuery();
    }
    BitSetProducer parentFilter;
    BitSetProducer childFilter;
    SchemaField sf;
    try {
        AllParentsAware bjQ;
        if (!(query instanceof AllParentsAware)) {
            throw new SyntaxError("expect a reference to block join query " + AllParentsAware.class.getSimpleName() + " in " + fp.getString());
        }
        bjQ = (AllParentsAware) query;
        parentFilter = BlockJoinParentQParser.getCachedFilter(fp.getReq(), bjQ.getParentQuery()).filter;
        childFilter = BlockJoinParentQParser.getCachedFilter(fp.getReq(), bjQ.getChildQuery()).filter;
        if (sortFieldName == null || sortFieldName.equals("")) {
            throw new SyntaxError("field is omitted in " + fp.getString());
        }
        sf = fp.getReq().getSchema().getFieldOrNull(sortFieldName);
        if (null == sf) {
            throw new SyntaxError(NAME + " sort param field \"" + sortFieldName + "\" can't be found in schema");
        }
    } catch (SyntaxError e) {
        log.error("can't parse " + fp.getString(), e);
        throw e;
    }
    return new BlockJoinSortFieldValueSource(childFilter, parentFilter, sf);
}
Also used : SchemaField(org.apache.solr.schema.SchemaField) Query(org.apache.lucene.search.Query) QueryBitSetProducer(org.apache.lucene.search.join.QueryBitSetProducer) BitSetProducer(org.apache.lucene.search.join.BitSetProducer) SyntaxError(org.apache.solr.search.SyntaxError) AllParentsAware(org.apache.solr.search.join.BlockJoinParentQParser.AllParentsAware)

Aggregations

Query (org.apache.lucene.search.Query)1 BitSetProducer (org.apache.lucene.search.join.BitSetProducer)1 QueryBitSetProducer (org.apache.lucene.search.join.QueryBitSetProducer)1 SchemaField (org.apache.solr.schema.SchemaField)1 SyntaxError (org.apache.solr.search.SyntaxError)1 AllParentsAware (org.apache.solr.search.join.BlockJoinParentQParser.AllParentsAware)1