lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Elschot <>
Subject Re: SpanQuery parser?
Date Wed, 19 Oct 2005 23:09:21 GMT
On Thursday 20 October 2005 00:40, Sean O'Connor wrote:
> Hello,
>     I have user entered search commands which I want to convert to 
> SpanQueries. I have seen in the book "Lucene in Action" that no parser 
> existed at time of publication, but there was someone working on a 
> SpanQuery parser. Can anyone point me to that code, or provide any 
> suggestions?
>     I want to use SpanQueries for their detail on the number of hits 
> from a query, and more importantly, the location (position start and 
> end) of each hit. My application requires me to do precise hit 
> highlighting.  I also need to perform calculations on the number of hits 
> per document, as well as per query (sum of document hits).

You may want to use the getSpans() method of SpanQuery and operate
on the result directly.

>     It is fairly critical I highlight the hits, and only the hits. From 
> what I've read SpanQueries (with dumpSpans) is a better approach than 
> using 'regular' queries. I _think_ regular queries currently use a 
> highlighter which shows all terms highlighted. This can give more 
> highlighting than actual hits (i.e false positives).
>     So, that being said, should I stick with SpanQueries? Is there any 
> current work on a parser to convert a string, or regular (Token, 
> Boolean, Phrase, Prefix,...) query into a SpanQuery?
>     I have written some very duct tape-ish code which will convert basic 
> booleanOR and prefix queries into SpanQueries. I just realized I'm in 
> deeper water than I expected when I tried converting my first query 
> string containing several boolean queries, AND a phrase query. So now I 
> am looking to either help an existing effort, or just continue with my 
> own hacking.


Have a look at the surround query parser in the svn trunk:

There is also some code that does highlighting based on Spans,
but I don't know where that is. Hopefully someone else can point you at that.

Paul Elschot

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message