lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Re: Wildcard and Fuzzy queries - no best fragments generated - ??
Date Tue, 27 Dec 2005 20:13:19 GMT

On Dec 27, 2005, at 2:34 PM, Dmitry Goldenberg wrote:
> What do you mean by _rewriting_ the query?  I checked all the  
> classes in the highlighter package and did not see any mention of  
> having to rewrite.

 From Highlighter's package.html in it's javadocs:

<pre>
	IndexSearcher searcher = new IndexSearcher(ramDir);
	Query query = QueryParser.parse("Kenne*", FIELD_NAME, analyzer);
	query = query.rewrite(reader); //required to expand search terms
	Hits hits = searcher.search(query);

	Highlighter highlighter = new Highlighter(this, new QueryScorer 
(query));
	for (int i = 0; i &lt; hits.length(); i++)
	{
		String text = hits.doc(i).get(FIELD_NAME);
		TokenStream tokenStream = analyzer.tokenStream(FIELD_NAME, new  
StringReader(text));
		// Get 3 best fragments and seperate with a "..."
		String result = highlighter.getBestFragments(tokenStream, text, 3,  
"...");
		System.out.println(result);
	}
</pre>





> ________________________________
>
> From: Erik Hatcher [mailto:erik@ehatchersolutions.com]
> Sent: Tue 12/27/2005 11:03 AM
> To: java-user@lucene.apache.org
> Subject: Re: Wildcard and Fuzzy queries - no best fragments  
> generated - ??
>
>
>
> You have to _rewrite_ the Query for this to work.  This, I believe,
> is mentioned in the javadocs.
>
> I think you are hijacking a thread with your recent postings.  Please
> create a new message rather than reply to one and change the
> subject.  Thanks.
>
>         Erik
>
>
> On Dec 27, 2005, at 1:55 PM, Dmitry Goldenberg wrote:
>
>> Hello,
>>
>> While testing my code that integrates the Highlighter class from
>> org.apache.lucene.search.highlight, I found out that for wildcard
>> and fuzzy queries, it generates no best fragments.
>>
>> Any particular reason why that is the case?  Shouldn't the
>> highlighter be able to work just like with any other query and
>> highlight any matching token sequences?  E.g. if I'm searching for
>> lava~, I'd expect it to highlight words like lava, java, etc.  This
>> is the whole point of highlighting, is it not?
>>
>> Thanks,
>> - Dmitry
>>
>> ---------------------------------------------------------------------
>> 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


---------------------------------------------------------------------
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