lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simon Willnauer" <simon.willna...@googlemail.com>
Subject Re: About the use of HitCollector
Date Tue, 08 Aug 2006 10:15:32 GMT
Hey Andy,

It would be interesting how many ids you include into your query. I do
have just a couple of usergroups for that.
I create a BooleanQuery
BooleanQuery q = new BooleanQuery();

  q.add(new BooleanClause(new TermQuery(new
Term("idfield","id")),BooleanClause.Occur.MUST));

  QueryFilter filter = new QueryFilter(q);
  searcher.search(yourActualQuery,filter);

you can put your created filters into a HashSet or event better in a
weak hashset to cache the queryfilter and reuse them. The hash value
of a query filter depends on the acutal query so that should be fine.
Just have a look at QueryFilter#hashCode().

if you got a large set of ids take care on BooleanQuery.setMaxClauseCount()
You can also keep your filter if you close your indexwriter and
release a new indexsearcher as the queryfilter caches the reader
instance internally.

best regards simon

On 8/8/06, hu andy <andyhugb@gmail.com> wrote:
>
> Hey,Simon, thanks for your reply
> I have an ID Field in the index. For the efficiency of indexing speed, I put
> some fields in
> a database, because I found the total of fields in a Document will badly
> degrade the indexing speed. So for the search, I will first query the
> database to get a list of ID, then use the list to check whether the Lucene
> seached results should  be returned.
> Can you give some suggestion?
>
> Also can  you show me to how you use filter?
>
> 2006/8/8, Simon Willnauer <simon.willnauer@googlemail.com>:
> >
> Hey Andy,
>
> i don't know how you determinate whether a document has to be
> displayed or not but I use a filter to do such kind of jobs. We have a
> index for a specific website with personalized areas which should be
> searchable for users having corresponding usergroups. That works quiet
> well and you can use the filter cache e.g. cache the filter itself for
>  your queries.
>
> regards Simon
>
> On 8/7/06, hu andy <andyhugb@gmail.com> wrote:
> > Martin, Thank you for your reply.
> >
> > But the Lucene API said:
>  > This is called in an inner search loop. For good search performance,
> > implementations of this method should not call
> > Searcher.doc(int)<
> file:///E:/java/IR%20Library/lucene-1.9.1/lucene-1.9.1/docs/api/org/apache/lucene/search/Searcher.html#doc(int)>or
> > IndexReader.document(int)<
> file:///E:/java/IR%20Library/lucene-1.9.1/lucene-1.9.1/docs/api/org/apache/lucene/index/IndexReader.html#document(int)>on
> > every document number encountered
> >
> > Because I have to check a field in the document to determine whether I
> > should return the document. The total number of documents is about two
> > hundred thousand. So I'm afraid the
> > performance
> >
> >
> > 2006/8/7, Martin Braun < mbraun@uni-hd.de>:
> > >
> > > hi andy,
> > > > How can I  use HitCollector to iterate over every returned document?
> > >
> > > You have to override the function collect for the HitCollector class and
> > > then store the retrieved Data in an array or map.
> > >
> > > Here is just a source-code scratch (is = IndexSearcher)
> > >
> > >                is.search(query, null, new HitCollector(){
> > >                                public void collect(int
> docID, float score)
> > >                                    {
> > >                                        Document doc =
> is.doc(docID);
>  > >                                        titles[docID] =
> doc.get("title");
> > >                                    }
> > >                        });
> > >
> > >
> > > hth,
> > > martin
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail:
> java-user-help@lucene.apache.org
> > >
> > >
> >
> >
>
> ---------------------------------------------------------------------
>
> To unsubscribe, e-mail:
> java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail:
> java-user-help@lucene.apache.org
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message