diff options
author | Pedro Giffuni <pfg@apache.org> | 2012-05-12 17:03:10 +0000 |
---|---|---|
committer | Pedro Giffuni <pfg@apache.org> | 2012-05-12 17:03:10 +0000 |
commit | 2fd86ba713150583c820fd1f6460216c00b83688 (patch) | |
tree | 609998350380a015c923063fa4844aa7185dcfe4 /xmlhelp | |
parent | f7087b0eeacf1377033b691b48c764029d914d24 (diff) |
Update Apache Lucene core to version 2.9.4.
The new version brings in many bugfixes and performance
improvements. Unfortunately this also means we lose the
Windows specific enhancements in the long_path.patch but
it must be expected the newer versions of Lucene will
have much better portability.
We also bring in support for using preinstalled version 3
from BZ i115241 (author: bero@arklinux).
Notes
Notes:
ignore: obsolete - use clucene
Diffstat (limited to 'xmlhelp')
-rw-r--r-- | xmlhelp/source/com/sun/star/help/HelpIndexer.java | 8 | ||||
-rw-r--r-- | xmlhelp/source/com/sun/star/help/HelpSearch.java | 22 | ||||
-rw-r--r-- | xmlhelp/source/com/sun/star/help/makefile.mk | 4 |
3 files changed, 16 insertions, 18 deletions
diff --git a/xmlhelp/source/com/sun/star/help/HelpIndexer.java b/xmlhelp/source/com/sun/star/help/HelpIndexer.java index b62274223c64..af9aa9176e41 100644 --- a/xmlhelp/source/com/sun/star/help/HelpIndexer.java +++ b/xmlhelp/source/com/sun/star/help/HelpIndexer.java @@ -36,14 +36,6 @@ import java.io.IOException; import java.util.Date; import java.util.zip.ZipOutputStream; -/** - When this tool is used with long path names on Windows, that is paths which start - with \\?\, then the caller must make sure that the path is unique. This is achieved - by removing '.' and '..' from the path. Paths which are created by - osl_getSystemPathFromFileURL fulfill this requirement. This is necessary because - lucene is patched to not use File.getCanonicalPath. See long_path.patch in the lucene - module. - */ public class HelpIndexer extends WeakBase implements XServiceInfo, XInvocation { diff --git a/xmlhelp/source/com/sun/star/help/HelpSearch.java b/xmlhelp/source/com/sun/star/help/HelpSearch.java index a42c2ddfa99f..0f7f31566921 100644 --- a/xmlhelp/source/com/sun/star/help/HelpSearch.java +++ b/xmlhelp/source/com/sun/star/help/HelpSearch.java @@ -40,16 +40,21 @@ import org.apache.lucene.analysis.cjk.CJKAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; -import org.apache.lucene.search.Hits; +import org.apache.lucene.search.TopDocs; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.Query; import org.apache.lucene.search.Searcher; +import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.WildcardQuery; +import org.apache.lucene.util.Version; +import org.apache.lucene.store.NIOFSDirectory; import com.sun.star.script.XInvocation; import com.sun.star.beans.XIntrospectionAccess; +import java.io.File; + /** This class capsulates the class, that implements the minimal component and a * factory for creating the service (<CODE>__getComponentFactory</CODE>). */ @@ -249,9 +254,10 @@ public class HelpSearch private static String[] queryImpl( String aLanguageStr, String aIndexStr, String aQueryStr, boolean bCaptionOnly, Object[] aScoreOutArray ) throws Exception { - IndexReader reader = IndexReader.open( aIndexStr ); + File aIndexFile = new File( aIndexStr ); + IndexReader reader = IndexReader.open( NIOFSDirectory.open( aIndexFile ), true ); Searcher searcher = new IndexSearcher( reader ); - Analyzer analyzer = aLanguageStr.equals("ja") ? (Analyzer)new CJKAnalyzer() : (Analyzer)new StandardAnalyzer(); + Analyzer analyzer = aLanguageStr.equals("ja") ? (Analyzer)new CJKAnalyzer(Version.LUCENE_29) : (Analyzer)new StandardAnalyzer(Version.LUCENE_29); String aField; if( bCaptionOnly ) @@ -266,18 +272,18 @@ public class HelpSearch aQuery = new TermQuery( new Term( aField, aQueryStr ) ); // Perform search - Hits aHits = searcher.search( aQuery ); - int nHitCount = aHits.length(); + TopDocs aHits = searcher.search( aQuery, 100 ); + int nHitCount = aHits.totalHits; String aDocs[] = new String[nHitCount]; float aScores[] = null; aScores = new float[nHitCount]; for( int iHit = 0 ; iHit < nHitCount ; iHit++ ) { - Document aDoc = aHits.doc( iHit ); - String aPath = aDoc.get( "path" ); + ScoreDoc aDoc = aHits.scoreDocs[iHit]; + String aPath = searcher.doc(aDoc.doc).get( "path" ); aDocs[iHit] = ( aPath != null ) ? aPath : ""; - aScores[iHit] = aHits.score( iHit ); + aScores[iHit] = aDoc.score; } aScoreOutArray[0] = aScores; diff --git a/xmlhelp/source/com/sun/star/help/makefile.mk b/xmlhelp/source/com/sun/star/help/makefile.mk index e3cd8de629aa..32d0db59ad25 100644 --- a/xmlhelp/source/com/sun/star/help/makefile.mk +++ b/xmlhelp/source/com/sun/star/help/makefile.mk @@ -47,8 +47,8 @@ JARFILES = ridl.jar jurt.jar unoil.jar juh.jar EXTRAJARFILES = $(LUCENE_CORE_JAR) $(LUCENE_ANALYZERS_JAR) JARCLASSPATH = $(EXTRAJARFILES) .ELSE -JARFILES += lucene-core-2.3.jar lucene-analyzers-2.3.jar -JARCLASSPATH = lucene-core-2.3.jar lucene-analyzers-2.3.jar +JARFILES += lucene-core-2.9.4-dev.jar lucene-analyzers-2.9.4-dev.jar +JARCLASSPATH = lucene-core-2.9.4-dev.jar lucene-analyzers-2.9.4-dev.jar .ENDIF JARTARGET = LuceneHelpWrapper.jar |