lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Boyd <andrew.b...@mindspring.com>
Subject Highlighter problem with SpanNearQuery w/Fix
Date Tue, 14 Jun 2005 19:57:38 GMT
Hi All,
  I have overidden QueryParser's getFieldQuery() so that it returns a SpanNearQuery instead
of a PhraseQuery.
 but that stopped the Highlighter working.  I added the following to QueryTermExtractor:


	private static final void getTerms(Query query, HashSet terms,boolean prohibited)
	{
		if (query instanceof BooleanQuery)
			getTermsFromBooleanQuery((BooleanQuery) query, terms, prohibited);
		else
			if (query instanceof PhraseQuery)
				getTermsFromPhraseQuery((PhraseQuery) query, terms);
			else
				if (query instanceof TermQuery)
					getTermsFromTermQuery((TermQuery) query, terms);
        else
                    if(query instanceof SpanNearQuery)  // <<< new <<<<
                        getTermsFromSpanNearQuery((SpanNearQuery) query, terms);

// and 

    private static final void getTermsFromSpanNearQuery(SpanNearQuery query, HashSet terms){
        Collection queryTerms = query.getTerms();
        for(Iterator iterator = queryTerms.iterator(); iterator.hasNext();){
            // break it out for debugging.
            Term term = (Term) iterator.next();
            String text = term.text();
            terms.add(new WeightedTerm(query.getBoost(), text));

        }
    }

And that seemed to fix it.

Hope this helps,
Andrew

Andrew Boyd
Software Architect
Sun Certified J2EE Architect
B&B Technical Services Inc.
205.422.2557

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