Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r324 - in trunk: java/ch/idok/common/lucene java/ch/idok/dmsd/impl/indexer/lucene java/ch/idok/service/server/search/lucene lib

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r324 - in trunk: java/ch/idok/common/lucene java/ch/idok/dmsd/impl/indexer/lucene java/ch/idok/service/server/search/lucene lib


Chronological Thread 
  • From: "AFS account Stadler Hans Christian" <stadler_h AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r324 - in trunk: java/ch/idok/common/lucene java/ch/idok/dmsd/impl/indexer/lucene java/ch/idok/service/server/search/lucene lib
  • Date: Mon, 23 Feb 2009 17:52:47 +0100
  • List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
  • List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>

Author: stadler_h
Date: Mon Feb 23 17:52:46 2009
New Revision: 324

Log:
Lucene 2.4.0

Modified:
trunk/java/ch/idok/common/lucene/DefaultAnalyzer.java
trunk/java/ch/idok/dmsd/impl/indexer/lucene/Indexer.java
trunk/java/ch/idok/service/server/search/lucene/LuceneSearchService.java
trunk/lib/lucene-core.jar
trunk/lib/lucene-highlighter.jar

Modified: trunk/java/ch/idok/common/lucene/DefaultAnalyzer.java
==============================================================================
--- trunk/java/ch/idok/common/lucene/DefaultAnalyzer.java (original)
+++ trunk/java/ch/idok/common/lucene/DefaultAnalyzer.java Mon Feb 23
17:52:46 2009
@@ -68,15 +68,13 @@
* value.
*/
@Override
- public Token next() throws IOException {
- Token token = input.next();
+ public Token next(Token reusable) throws IOException {
+ Token token = input.next(reusable);
if (token == null)
return token;
try {
- long value = Long.parseLong(token.termText());
- String text = NumberTools.longToString(value);
- token = new Token(text, token.startOffset(),
token.endOffset(),
- token.type());
+ long value = Long.parseLong(token.term());
+ reusable.reinit(token, NumberTools.longToString(value));
} catch (NumberFormatException ex) { /* ignore */
}
return token;

Modified: trunk/java/ch/idok/dmsd/impl/indexer/lucene/Indexer.java
==============================================================================
--- trunk/java/ch/idok/dmsd/impl/indexer/lucene/Indexer.java (original)
+++ trunk/java/ch/idok/dmsd/impl/indexer/lucene/Indexer.java Mon Feb 23
17:52:46 2009
@@ -36,9 +36,9 @@
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
-import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.TopDocs;

import ch.idok.common.errorhandling.DmsException;
import ch.idok.common.errorhandling.ErrorType;
@@ -125,7 +125,7 @@
*/
private void setIndexWriter(boolean createIndex, boolean setSearcher)
throws Throwable {
- indexWriter = new IndexWriter(indexDirectory, analyzer, createIndex);
+ indexWriter = new IndexWriter(indexDirectory, analyzer, createIndex,
IndexWriter.MaxFieldLength.UNLIMITED);
indexWriter.setMergeFactor(20);
indexWriter.setMaxBufferedDocs(15);
if (setSearcher)
@@ -202,8 +202,8 @@
.getDocumentId().toString()
: path.getRelativeId();
Term idTerm = new Term(metaKey, docId);
- Hits hits = indexSearcher.search(new TermQuery(idTerm));
- if (hits.length() != 0) {
+ TopDocs hits = indexSearcher.search(new TermQuery(idTerm),
null, 1);
+ if (hits.totalHits != 0) {
logger.finest("Found " + docId + " in index");
if (indexingMode == IndexingMode.LAST_VERSION) {
logger.info("Deleting existing document " + docId
@@ -263,7 +263,7 @@
charBuf = null;
luceneDocument.add(new Field("content", stringWriter
.toString(), Field.Store.COMPRESS,
- Field.Index.TOKENIZED));
+ Field.Index.ANALYZED));
stringWriter.close();
sb.append("Added field: content\n");
String version = metadata.get(ch.idok.common.config.Setup
@@ -277,13 +277,13 @@
for (String metaDatum : metadata.keySet()) {
String metaValue = metadata.get(metaDatum);
luceneDocument.add(new Field(metaDatum, metaValue,
- Field.Store.YES, Field.Index.TOKENIZED));
+ Field.Store.YES, Field.Index.ANALYZED));
sb.append("Added field: " + metaDatum + ", size: "
+ metaDatum.length() + metaValue.length()
+ "\n");
}
luceneDocument.add(new Field(metaKey, docId,
- Field.Store.YES, Field.Index.UN_TOKENIZED));
+ Field.Store.YES, Field.Index.NOT_ANALYZED));
sb.append("Added field: " + metaKey + "\n");
sb.append("Adding document, docCounter=" + docCounter
+ "\n");
@@ -346,7 +346,7 @@
logger.finest("Received signal " + signal + " from " +
originator);
if (signal == PipelineSignal.START) {
IndexWriter indexWriter = new IndexWriter(indexDirectory,
- analyzer, !indexDirectory.isDirectory());
+ analyzer, !indexDirectory.isDirectory(),
IndexWriter.MaxFieldLength.UNLIMITED);
indexWriter.close();
if (!indexDirectory.isDirectory())
logger

Modified:
trunk/java/ch/idok/service/server/search/lucene/LuceneSearchService.java
==============================================================================
--- trunk/java/ch/idok/service/server/search/lucene/LuceneSearchService.java
(original)
+++ trunk/java/ch/idok/service/server/search/lucene/LuceneSearchService.java
Mon Feb 23 17:52:46 2009
@@ -43,10 +43,10 @@
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.BooleanQuery;
-import org.apache.lucene.search.Hits;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Searcher;
+import org.apache.lucene.search.TopDocs;
import org.apache.lucene.search.highlight.Formatter;
import org.apache.lucene.search.highlight.Highlighter;
import org.apache.lucene.search.highlight.QueryScorer;
@@ -321,7 +321,7 @@
/** @brief The lucene search object for the query */
public Searcher searcher;
/** @brief The lucene query hits */
- public Hits hits;
+ public TopDocs hits;
/** @brief The next hit index */
public int nextHit;
/** @brief The number of hits */
@@ -339,14 +339,14 @@
* Lucene hits
*/
public RepoSearch(HitIterator hi, String idx, String rpo,
- Searcher srch, Hits hts) {
+ Searcher srch, TopDocs hts) {
iter = hi;
index = idx;
repository = rpo;
searcher = srch;
hits = hts;
nextHit = 0;
- numHits = hits.length();
+ numHits = hits.totalHits;
}

/** @brief Release all resources referenced by this object. */
@@ -417,10 +417,10 @@
for (String repo : repos) {
String indexDir = indexIterator.next();
Searcher searcher;
- Hits hits;
+ TopDocs hits;
try {
searcher = getIndexSearcher(indexDir);
- hits = searcher.search(query);
+ hits = searcher.search(query, null, Integer.MAX_VALUE);
RepoSearch repoSearch = new RepoSearch(this, indexDir,
repo, searcher, hits);
repohits.add(repoSearch);
@@ -472,7 +472,7 @@
rs.destroy();
continue;
}
- float score = rs.hits.score(rs.nextHit);
+ float score = rs.hits.scoreDocs[rs.nextHit].score;
if (maxScore >= score)
continue;
bestHit = rs;
@@ -483,8 +483,8 @@
else {
logger.finest(this + " - returning hit number "
+ returnedHits++);
- return new MatchingDoc(bestHit, bestHit.hits
- .doc(bestHit.nextHit++));
+ return new MatchingDoc(bestHit,
bestHit.searcher.doc(bestHit.hits
+ .scoreDocs[bestHit.nextHit++].doc));
}
} catch (IOException ex) {
logger.warning(ex.getLocalizedMessage());

Modified: trunk/lib/lucene-core.jar
==============================================================================
Binary files. No diff available.

Modified: trunk/lib/lucene-highlighter.jar
==============================================================================
Binary files. No diff available.



  • [idok-commit] idok commit r324 - in trunk: java/ch/idok/common/lucene java/ch/idok/dmsd/impl/indexer/lucene java/ch/idok/service/server/search/lucene lib, AFS account Stadler Hans Christian, 02/23/2009

Archive powered by MHonArc 2.6.19.

Top of Page