lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bouadjenek mohamed reda <redateksys...@gmail.com>
Subject Lucene filter
Date Fri, 02 Dec 2016 06:30:53 GMT
Hi All,


I wanna use a filter into a query (BooleanClause.Occur.FILTER). For
example, my query is:

#repository:clinicaltrials +title:multipl

It looks like when I build the query from this String, the filter is not
working. In other words, the total hits in the first example below is
different from total hits in the second example below. Please, does anyone
know what wrong with this simple example?

Example 1:
String query = "#repository:clinicaltrials +title:multipl";
QueryParser qr = new QueryParser("", new StandardAnalyzer());
TopDocs hits = is.search(qr.parse(query), 1);

Example 2:
String[] fields = new String[]{"repository", "title"};
BooleanClause.Occur[] allflags = new
BooleanClause.Occur[]{BooleanClause.Occur.FILTER,
BooleanClause.Occur.MUST};
String[] query_text = new String[]{"clinicaltrials", "multipl"};
Query finalQuery = MultiFieldQueryParser.parse(query_text, fields,
allflags, new StandardAnalyzer());
TopDocs hits = is.search(finalQuery, 1);


thanks,


Best,
reda

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message