It looks like your dates are well formatted for lexicographic ordering, so to check whether a value is between two different fields will follow a pattern like. Lucene didn't begin supporting open-ended queries in the StandardQueryParser until version 3.6, so selecting adequantely large upper and lower bounds, to emulate an open ended query:
+EffectiveDate:[0000-01-01 TO value] +ExpirationDate:[value TO 9999-12-31]
Which, I believe, won't work well with MultiFieldQueryParser
. You may need to run the rest of your Query through that parser, and something like the above through a StandardQueryParser
and merge them with a BooleanQuery
.
you could also construct the same query manually, something like:
TermRangeQuery tqlow = new TermRangeQuery("EffectiveDate", null, new BYtesRef(value), true, true);
TermRangeQuery tqlow = new TermRangeQuery("ExpirationDate", new BYtesRef(value), null, true, true);
BooleanQuery betweenQuery = new BooleanQuery();
betweenQuery.add(new BooleanClause(tqlow, BooleanClause.Occur.MUST));
betweenQuery.add(new BooleanClause(tqhigh, BooleanClause.Occur.MUST));
Query parsedQuery = MultiFieldQueryParser.parse............
BooleanQuery rootQuery = new BooleanQuery();
rootQuery.add(new BooleanClause(parsedQuery, BooleanClause.Occur.MUST));
rootQuery.add(new BooleanClause(betweenQuery, BooleanClause.Occur.MUST));