lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rasik Pandey" <rasik.pan...@ajlsm.com>
Subject RE : Performance of hit highlighting and finding term positions for a specific document
Date Wed, 31 Mar 2004 12:39:46 GMT
Hello,

> I've been meaning to look into good ways to store token offset
> information to allow for very
> efficient highlighting and I believe Mark may also be looking
> into improving the highlighter via
> other means such as temporary ram indexes. Search the archives
> to get a background on some of the
> idea's we've tossed around ('Dmitry's Term Vector stuff, plus
> some' and 'Demoting results' come to
> mind as threads that touch this topic).

I would be nice if CachingRewrittenQueryWrapper.java that I sent to lucene-dev (see below)
last week became part of these highlighting effors, if appropriate. We use it to collect terms
for a query that searches of multiple indices.

Regards,
RBP





> -----Message d'origine-----
> De : Rasik Pandey [mailto:rasik.pandey@ajlsm.com]
> Envoyé : mercredi 17 mars 2004 13:36
> À : 'Lucene Developers List'; korfut@lycos.com
> Objet : RE : Query Term Collector (was: Re: New highlighter
> package available)
> 
> Hello All,
> 
> I don't know how this Thread/issue was resolved, but if you are
> still interested I have a simple way of doing this term
> collection ONLY at query time. I've tested it and it works with
> highlighting, etc. without the extra rewrite() call on the
> index.
> 
> Comments are welcome!
> 
> 
> package org.apache.lucene.search;
> 
> import org.apache.lucene.search.Weight;
> import org.apache.lucene.search.Searcher;
> import org.apache.lucene.search.Query;
> import org.apache.lucene.search.Similarity;
> import org.apache.lucene.index.IndexReader;
> 
> import java.io.IOException;
> 
> /*Rasik Pandey rasik.pandey@ajlsm.com*/
> /**Simple wrapper for a Lucene query that
>  * collects all queries generated by calling
>  * rewrite on the original Lucene query and stores
>  * them in a BooleanQuery.
>  *
>  * A Searcher will call the rewrite() method
>  * for each index and hence generate a query
>  * containing terms for the respective index. This
>  * class collects these queries so that they may be
>  * used for highlighting, query expansion, etc. by
>  * retrieving the underlying terms.
>  *
>  * @see #rewrite
>  * @see #getRewrittenQueries
>  * @see #resetRewrittenQueries
>  * @see #getOriginalQuery
>  */
> public class CachingRewrittenQueryWrapper extends Query{
>     protected org.apache.lucene.search.Query originalQuery =
> null;
>     protected BooleanQuery rewrittenQueries = new
> BooleanQuery();
> 
>     public CachingRewrittenQueryWrapper(Query originalQuery) {
>         this.originalQuery = originalQuery;
>     }
> 
>     public BooleanQuery getRewrittenQueries() {
>         return this.rewrittenQueries;
>     }
> 
>     public void resetRewrittenQueries() {
>         BooleanQuery newCachedQuery = new BooleanQuery();
> 
> newCachedQuery.setMaxClauseCount(this.rewrittenQueries.getMaxCl
> auseCount());
>         this.rewrittenQueries = newCachedQuery;
>     }
> 
>     public Query getOriginalQuery() {
>         return this.originalQuery;
>     }
> 
>     public void setBoost(float b) {
>         this.originalQuery.setBoost(b);
>     }
> 
>     public float getBoost() {
>         return this.originalQuery.getBoost();
>     }
> 
> 
>     protected Weight createWeight(Searcher searcher) {
>         return this.originalQuery.createWeight(searcher);
>     }
> 
>     public Query rewrite(IndexReader reader) throws IOException
> {
>         Query rewrittenQuery =
> this.originalQuery.rewrite(reader);
>         this.rewrittenQueries.add(rewrittenQuery, false,
> false);
>         return rewrittenQuery;
>     }
> 
>     public Query combine(Query[] queries) {
>         return this.originalQuery.combine(queries);
>     }
> 
>     public Similarity getSimilarity(Searcher searcher) {
>         return this.originalQuery.getSimilarity(searcher);
>     }
> 
>     protected void finalize() throws Throwable {
>         super.finalize();
>         //TODO maybe something here to ensure that all
> resources held by rewrittenQueries are cleaned up properly
>     }
> 
>     public String toString() {
>         return this.originalQuery.toString();
>     }
> 
>     public String toString(String field) {
>        return this.originalQuery.toString(field);
>     }
> }
> 
> 
> 
> ---------------------------------------------------------------
> ------
> To unsubscribe, e-mail: lucene-dev-
> unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-
> help@jakarta.apache.org




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


Mime
View raw message