LUCENE-7263: Make queryparser/xml/CoreParser's SpanQueryBuilderFactory accessible to deriving classes. (Daniel Collins via Christine Poerschke)

This commit is contained in:
Christine Poerschke 2016-05-03 10:05:02 +01:00
parent 21b87bc7c4
commit 2fe824fd6e
2 changed files with 21 additions and 13 deletions

View File

@ -127,6 +127,9 @@ Other
* LUCENE-7210: Make TestCore*Parser's analyzer choice override-able
(Christine Poerschke, Daniel Collins)
* LUCENE-7263: Make queryparser/xml/CoreParser's SpanQueryBuilderFactory
accessible to deriving classes. (Daniel Collins via Christine Poerschke)
======================= Lucene 6.0.0 =======================
System Requirements

View File

@ -36,6 +36,7 @@ public class CoreParser implements QueryBuilder {
protected Analyzer analyzer;
protected QueryParser parser;
protected QueryBuilderFactory queryFactory;
final protected SpanQueryBuilderFactory spanFactory;
/**
@ -62,6 +63,8 @@ public class CoreParser implements QueryBuilder {
this.parser = parser;
queryFactory = new QueryBuilderFactory();
spanFactory = new SpanQueryBuilderFactory();
queryFactory.addBuilder("TermQuery", new TermQueryBuilder());
queryFactory.addBuilder("TermsQuery", new TermsQueryBuilder(analyzer));
queryFactory.addBuilder("MatchAllDocsQuery", new MatchAllDocsQueryBuilder());
@ -77,34 +80,32 @@ public class CoreParser implements QueryBuilder {
}
queryFactory.addBuilder("ConstantScoreQuery", new ConstantScoreQueryBuilder(queryFactory));
SpanQueryBuilderFactory sqof = new SpanQueryBuilderFactory();
SpanNearBuilder snb = new SpanNearBuilder(sqof);
sqof.addBuilder("SpanNear", snb);
SpanNearBuilder snb = new SpanNearBuilder(spanFactory);
spanFactory.addBuilder("SpanNear", snb);
queryFactory.addBuilder("SpanNear", snb);
BoostingTermBuilder btb = new BoostingTermBuilder();
sqof.addBuilder("BoostingTermQuery", btb);
spanFactory.addBuilder("BoostingTermQuery", btb);
queryFactory.addBuilder("BoostingTermQuery", btb);
SpanTermBuilder snt = new SpanTermBuilder();
sqof.addBuilder("SpanTerm", snt);
spanFactory.addBuilder("SpanTerm", snt);
queryFactory.addBuilder("SpanTerm", snt);
SpanOrBuilder sot = new SpanOrBuilder(sqof);
sqof.addBuilder("SpanOr", sot);
SpanOrBuilder sot = new SpanOrBuilder(spanFactory);
spanFactory.addBuilder("SpanOr", sot);
queryFactory.addBuilder("SpanOr", sot);
SpanOrTermsBuilder sots = new SpanOrTermsBuilder(analyzer);
sqof.addBuilder("SpanOrTerms", sots);
spanFactory.addBuilder("SpanOrTerms", sots);
queryFactory.addBuilder("SpanOrTerms", sots);
SpanFirstBuilder sft = new SpanFirstBuilder(sqof);
sqof.addBuilder("SpanFirst", sft);
SpanFirstBuilder sft = new SpanFirstBuilder(spanFactory);
spanFactory.addBuilder("SpanFirst", sft);
queryFactory.addBuilder("SpanFirst", sft);
SpanNotBuilder snot = new SpanNotBuilder(sqof);
sqof.addBuilder("SpanNot", snot);
SpanNotBuilder snot = new SpanNotBuilder(spanFactory);
spanFactory.addBuilder("SpanNot", snot);
queryFactory.addBuilder("SpanNot", snot);
}
@ -116,6 +117,10 @@ public class CoreParser implements QueryBuilder {
queryFactory.addBuilder(nodeName, builder);
}
public void addSpanBuilder(String nodeName, SpanQueryBuilder builder) {
spanFactory.addBuilder(nodeName, builder);
}
static Document parseXML(InputStream pXmlFile) throws ParserException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = null;