lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sawan Sharma" <ssha...@chambal.com>
Subject Facet searching on single field with multiple words value
Date Thu, 21 Jun 2007 04:31:17 GMT
Hi friends,

I tried to implement the facet searching in a sample code and when I tried
it with various case and found no result in one case.I wanted to narrow by
one field "title" and gave the multiple word or say phrase.

So First, in this preparing the lucene query and converting it into
QueryFilter.
Adding IndexReader to this filter query and converting it into BitSet.
and We are preparing TermQuery on the basis of lucene field and given
value(Getting the field and value dynamically and value can be single word
or multiple word). Adding this term query to query filter and again
converting it to BitSet.
so this has two different bitset, one is based on free text lucene query and
another is on the basis of field by which I need to narrow by. and doing the
following operation:-
<code>
 secondBitSet.and(FirstBitSet);
 int count=secondBitSet.cardinality();
<code>
Now, The problem occured when I passed the multiple words in term query.
e.g.<code>
QueryFilter filter = new QueryFilter(new TermQuery(new Term(FieldName,
FieldValue)));
<code>
where field name  and field value dynamically getting.
here we take the example value.
FieldName:- "Title"
FieldValue:- "Software Development" ot it may be "Software AND Development".
In this case i'm not getting the result. i.e . counts= 0.

Code is given below.
<code>
IndexReader reader = searcher.getIndexReader();
BitSet firstBitSet =  firstQueryFilter.bits(reader);

QueryFilter filter = new QueryFilter(new TermQuery(new Term(FieldName,
FieldValue)));
BitSet secondBitSet = filter.bits(reader);

secondBitSet.and (FirstBitSet);
int count=secondBitSet.cardinality();

</code>
-- 
Regards

Sawan

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