Hi,
I'm facing the problem solve to which appears to be just few simple lines
but i cannot manage to find them.
I'm using Lucene, 5.4.0
What I'm trying to do is to compose a complex BooleanQuery and at the end I
need to find an intersection of all subqueries without summing score of
subqueries for one result (I'd rather evaluate results by MAX).
Code:
String line = "query consisting of many words";
BooleanQuery.Builder builder = new BooleanQuery.Builder();
Query q;
String[] words = line.split(" ");
for (String word : words) {
q = getQuery(word); //getQuery returns boolean subquery
builder.add(q, Occur.MUST);
}
Query result = builder.build();
gives me intersection but is also summing scores. And another code:
String line = "query consisting of many words";
List<Query> l = new ArrayList<Query>();
Query q;
String[] words = line.split(" ");
for (String word : words) {
q = getQuery(word); //getQuery returns boolean subquery
l.add(q);
}
Query result = DisjunctionMaxQuery(l, 0f);
gives only MAX score for each hit but returns SUM of results of subqueries
instead of intersection.
What query should I use or how to change those to get wanted result? I know
that I could implement my own CustomScoreQuery, own Scorer and so on but i
really believe that there is easier way. Could you guys give me a hand
with that?
Thanks in advance,
Michał Klecha