lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrien RUFFIE <a.ruf...@e-deal.com>
Subject Lucene-analyzer 3.3.0 and Lucene snowball 3.0.1
Date Mon, 17 Dec 2012 17:41:59 GMT
Hello all,

I beginning with an application and nobody knows with Lucene-analyzer 3.3.0.jar and Lucene
snowball 3.0.1.jar are both included
Its do same thing ?

I how can I be sure that excluding Lucene-snowball jar in my application, it is not used (the
idea that it is Lucene-analyzer is used instead).

Thank best regards

Bien cordialement,

Adrien Ruffié
LD : +33 1 73 03 29 50
Tél : +33 1 73 03 29 80

E-DEAL
Innover la Relation Client

-----Message d'origine-----
De : Vitaly_Artemov@McAfee.com [mailto:Vitaly_Artemov@McAfee.com] 
Envoyé : lundi 17 décembre 2012 17:46
À : java-user@lucene.apache.org
Objet : Lucene 4.0.0 - find offsets for phrase queries

Hi all,
I use Lucene 4.0.
I try to find offsets for phrase queries.
My code works then I search for one word but then I call it for some phrase I didn't get offsets.
termsEnum.seekExact returns false for phrase queries.

reader = DirectoryReader.open( mIndexDir );
               IndexSearcher searcher = new IndexSearcher(reader);
               QueryParser parser = new QueryParser(Version.LUCENE_40, mField, mAnalyzer);
               Query query = parser.parse(aQuery);

               TopScoreDocCollector collector = TopScoreDocCollector.create(100, true);
               searcher.search(query, collector);
               ScoreDoc[] hits = collector.topDocs().scoreDocs;

               for(int i=0;i<hits.length;++i) {
                   int docId = hits[i].doc;

                   Document d = searcher.doc(docId);

                   Terms tfvector = reader.getTermVector(docId, "contents");

                   if( tfvector != null )
                   {
                      TermsEnum termsEnum = tfvector.iterator(null);

                      if ( termsEnum.seekExact(new BytesRef( aQuery.toLowerCase() ), false
) )
                      {
                             DocsAndPositionsEnum dpEnum = null;
                             dpEnum = termsEnum.docsAndPositions(null, dpEnum);

if( dpEnum != null )
                             {
                                   int freq = dpEnum.freq();

                                   int maxOcc = 20;

                                    while( freq-- > 0 && maxOcc-- > 0 ) {
                                          dpEnum.nextPosition();
                                         System.out.println("Start offset " + dpEnum.startOffset()
+ " End offset " + dpEnum.endOffset());
                                    }
                             }
}

What is the problem?

Thanks in advance, Vitaly.

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