Author: antoine Date: Wed Feb 21 18:55:26 2007 New Revision: 510360 URL: http://svn.apache.org/viewvc?view=rev&rev=510360 Log: Bugzilla 40915, upgrade to lucene 2.1.0
Added: jakarta/slide/trunk/lib/lucene-core-2.1.0.jar (with props) Removed: jakarta/slide/trunk/lib/lucene-1.4-final.jar Modified: jakarta/slide/trunk/WHATSNEW jakarta/slide/trunk/build.xml jakarta/slide/trunk/contributors.xml jakarta/slide/trunk/src/stores/org/apache/slide/index/BasicExpressionTxtContainsSample.java jakarta/slide/trunk/src/stores/org/apache/slide/index/LuceneIndexer.java jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContainsExpression.java jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContentIndexer.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/Index.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/AbstractLuceneExpression.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/BetweenExpression.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/EqExpression.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/LikeExpression.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/MergeExpression.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropcontainsExpression.java jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropertyContainsExpression.java Modified: jakarta/slide/trunk/WHATSNEW URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/WHATSNEW?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/WHATSNEW (original) +++ jakarta/slide/trunk/WHATSNEW Wed Feb 21 18:55:26 2007 @@ -24,4 +24,6 @@ * one change in org/apache/slide/store/ojb/property/ElementListPropertyHandler.java, store(PersistenceBroker broker, PropertyPeer propertyPeer, NodeProperty property) to be able to build in gump +* Migrate to Lucene 2.1.0 + Bugzilla 40915. Modified: jakarta/slide/trunk/build.xml URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/build.xml?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/build.xml (original) +++ jakarta/slide/trunk/build.xml Wed Feb 21 18:55:26 2007 @@ -45,7 +45,7 @@ <property name="commons-collections.jar" value="${lib.dir}/commons-collections-2.1.jar"/> <property name="commons-logging.jar" value="${lib.dir}/commons-logging-1.0.4.jar"/> <property name="commons-lang.jar" value="${lib.dir}/commons-lang-2.0.jar"/> - <property name="lucene.jar" value="${lib.dir}/lucene-1.4-final.jar"/> + <property name="lucene.jar" value="${lib.dir}/lucene-core-2.1.0.jar"/> <property name="poi.jar" value="${lib.dir}/poi-2.5-final-20040428.jar"/> <property name="pdfbox.jar" value="${lib.dir}/PDFBox-0.6.5.jar"/> <property name="tm-extractors.jar" value="${lib.dir}/tm-extractors-0.4.jar"/> Modified: jakarta/slide/trunk/contributors.xml URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/contributors.xml?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/contributors.xml (original) +++ jakarta/slide/trunk/contributors.xml Wed Feb 21 18:55:26 2007 @@ -15,6 +15,10 @@ These are some of the many people who have helped Slide become so successful. </introduction> <name> + <first>Benjamin</first> + <last>Lerman</last> + </name> + <name> <first>Eric</first> <last>Van</last> </name> Added: jakarta/slide/trunk/lib/lucene-core-2.1.0.jar URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/lib/lucene-core-2.1.0.jar?view=auto&rev=510360 ============================================================================== Binary file - no diff available. Propchange: jakarta/slide/trunk/lib/lucene-core-2.1.0.jar ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/BasicExpressionTxtContainsSample.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/BasicExpressionTxtContainsSample.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/BasicExpressionTxtContainsSample.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/BasicExpressionTxtContainsSample.java Wed Feb 21 18:55:26 2007 @@ -113,7 +113,7 @@ Searcher searcher = new IndexSearcher(indexPath); Analyzer analyzer = new StandardAnalyzer(); - Query query = QueryParser.parse(searchedText, "contents", analyzer); + Query query = new QueryParser("contents", analyzer).parse(searchedText); Hits hits = searcher.search (query); int noOfHits = hits.length(); Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/LuceneIndexer.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/LuceneIndexer.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/LuceneIndexer.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/LuceneIndexer.java Wed Feb 21 18:55:26 2007 @@ -35,6 +35,8 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.Field.Index; +import org.apache.lucene.document.Field.Store; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; @@ -81,7 +83,7 @@ IndexReader reader = IndexReader.open(directory); Term deleteTerm = new Term(DOC_ID, docId); - reader.delete(deleteTerm); + reader.deleteDocuments(deleteTerm); reader.close(); directory.close(); } @@ -104,8 +106,10 @@ // reader = new FileReader (docId); Document doc = new Document(); - doc.add (Field.Text ("contents", reader)); - Field field = new Field(DOC_ID, docId, true, true, true); + Field field = null; + field = new Field("contents", reader); + doc.add (field); + field = new Field(DOC_ID, docId, Store.YES, Index.TOKENIZED); doc.add(field); writer.addDocument(doc); writer.optimize(); @@ -124,7 +128,7 @@ Searcher searcher = new IndexSearcher (indexDb); Analyzer analyzer = new StandardAnalyzer(); - Query query = QueryParser.parse(stringToFind, "contents", analyzer); + Query query = new QueryParser("contents", analyzer).parse(stringToFind); Hits hits = searcher.search(query); Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContainsExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContainsExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContainsExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContainsExpression.java Wed Feb 21 18:55:26 2007 @@ -109,7 +109,7 @@ { Searcher searcher = new IndexSearcher(indexPath); - Query query = QueryParser.parse(searchedText, TextContentIndexer.CONTENT_TEXT, analyzer); + Query query = new QueryParser(TextContentIndexer.CONTENT_TEXT, analyzer).parse(searchedText); Hits hits = searcher.search (query); int noOfHits = hits.length(); Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContentIndexer.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContentIndexer.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContentIndexer.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/TextContentIndexer.java Wed Feb 21 18:55:26 2007 @@ -42,6 +42,8 @@ import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.Field.Index; +import org.apache.lucene.document.Field.Store; import java.io.IOException; import java.io.CharArrayReader; @@ -140,14 +142,14 @@ // Create document Document doc = new Document(); - doc.add(Field.Keyword(URI_FIELD, uri.toString())); - doc.add(Field.Text(CONTENT_TEXT, readContent(revisionDescriptor, revisionContent))); + doc.add(new Field(URI_FIELD, uri.toString(), Store.YES, Index.UN_TOKENIZED)); + doc.add(new Field(CONTENT_TEXT, readContent(revisionDescriptor, revisionContent))); if ( revisionContent != null && revisionDescriptor != null ) { List extractor = ExtractorManager.getInstance().getContentExtractors(uri.getNamespace().getName(), (NodeRevisionDescriptors)null, revisionDescriptor); for ( int i = 0, l = extractor.size(); i < l; i++ ) { Reader reader = ((ContentExtractor)extractor.get(i)).extract(new ByteArrayInputStream(revisionContent.getContentBytes())); - doc.add(Field.Text(CONTENT_TEXT, reader)); + doc.add(new Field(CONTENT_TEXT, reader)); } } @@ -207,7 +209,7 @@ IndexReader indexReader = IndexReader.open(indexpath); Term term = new Term(URI_FIELD, uri.toString()); - indexReader.delete(term); + indexReader.deleteDocuments(term); indexReader.close(); indexWriter = new IndexWriter(indexpath, analyzer, false); @@ -215,14 +217,14 @@ // Create document Document doc = new Document(); - doc.add(Field.Keyword(URI_FIELD, uri.toString())); - doc.add(Field.Text(CONTENT_TEXT, readContent(revisionDescriptor, revisionContent))); + doc.add(new Field(URI_FIELD, uri.toString(), Store.YES, Index.UN_TOKENIZED)); + doc.add(new Field(CONTENT_TEXT, readContent(revisionDescriptor, revisionContent))); if ( revisionContent != null && revisionDescriptor != null ) { List extractor = ExtractorManager.getInstance().getContentExtractors(uri.getNamespace().getName(), (NodeRevisionDescriptors)null, revisionDescriptor); for ( int i = 0, l = extractor.size(); i < l; i++ ) { Reader reader = ((ContentExtractor)extractor.get(i)).extract(new ByteArrayInputStream(revisionContent.getContentBytes())); - doc.add(Field.Text(CONTENT_TEXT, reader)); + doc.add(new Field(CONTENT_TEXT, reader)); } } @@ -279,7 +281,7 @@ IndexReader indexReader = IndexReader.open(indexpath); Term term = new Term(URI_FIELD, uri.toString()); - indexReader.delete(term); + indexReader.deleteDocuments(term); indexReader.close(); indexWriter = new IndexWriter(indexpath, analyzer, false); Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/Index.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/Index.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/Index.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/Index.java Wed Feb 21 18:55:26 2007 @@ -39,6 +39,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.document.Field.Store; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.Term; @@ -215,19 +216,19 @@ } private Field unstoredString(String fieldName, String value) { - return new Field(fieldName, value, false, true, false); + return new Field(fieldName, value, Store.NO, org.apache.lucene.document.Field.Index.UN_TOKENIZED); } private Field storedString(String fieldName, String value) { - return new Field(fieldName, value, true, true, false); + return new Field(fieldName, value, Store.YES, org.apache.lucene.document.Field.Index.UN_TOKENIZED); } private Field textField(String fieldName, String value) { - return new Field(fieldName, value, false, true, true); + return new Field(fieldName, value, Store.NO, org.apache.lucene.document.Field.Index.TOKENIZED); } private Field textField(String fieldName, Reader value) { - return Field.Text(fieldName, value); + return new Field(fieldName, value); } /** @@ -407,7 +408,7 @@ logger.log("remove: " + job.key, LOG_CHANNEL, Logger.DEBUG); } - reader.delete(new Term(Index.KEY_FIELD_NAME, job.getKey())); + reader.deleteDocuments(new Term(Index.KEY_FIELD_NAME, job.getKey())); this.jobCounter++; } reader.close(); Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/AbstractLuceneExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/AbstractLuceneExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/AbstractLuceneExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/AbstractLuceneExpression.java Wed Feb 21 18:55:26 2007 @@ -33,6 +33,7 @@ import org.apache.lucene.document.Document; import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Hits; import org.apache.lucene.search.IndexSearcher; @@ -138,10 +139,10 @@ BooleanQuery booleanQuery = new BooleanQuery(); if (luceneQuery != null) - booleanQuery.add(luceneQuery, true, false); + booleanQuery.add(luceneQuery, BooleanClause.Occur.MUST); if (Configuration.useGlobalBinding()) { booleanQuery.add(new TermQuery( - new Term(Index.SCOPE_FIELD_NAME, "/")), true, false); + new Term(Index.SCOPE_FIELD_NAME, "/")), BooleanClause.Occur.MUST); booleanQuery .add( new RangeQuery( @@ -157,10 +158,10 @@ + q .getScope() .getDepth())), - true), true, false); + true), BooleanClause.Occur.MUST); } else { booleanQuery.add(new TermQuery(new Term(Index.SCOPE_FIELD_NAME, - scope)), true, false); + scope)), BooleanClause.Occur.MUST); int queryScopeHrefDepth = getDepth(scope); @@ -171,7 +172,7 @@ case QueryScope.DEPTH_0: booleanQuery.add(new TermQuery(new Term(Index.DEPTH_FIELD_NAME, index.getConfiguration().intToIndexString( - getDepth(scope)))), true, false); + getDepth(scope)))), BooleanClause.Occur.MUST); break; case QueryScope.DEPTH_1: default: @@ -182,7 +183,7 @@ .intToIndexString( getDepth(scope) + q.getScope().getDepth())), - true), true, false); + true), BooleanClause.Occur.MUST); } } @@ -325,8 +326,8 @@ protected Query negateQuery(Query query) { BooleanQuery booleanQuery = new BooleanQuery(); - booleanQuery.add(allQuery(), true, false); - booleanQuery.add(query, false, true); + booleanQuery.add(allQuery(), BooleanClause.Occur.MUST); + booleanQuery.add(query, BooleanClause.Occur.MUST_NOT); return booleanQuery; } Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/BetweenExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/BetweenExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/BetweenExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/BetweenExpression.java Wed Feb 21 18:55:26 2007 @@ -23,6 +23,7 @@ package org.apache.slide.index.lucene.expressions; import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.RangeQuery; @@ -127,11 +128,8 @@ BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add( new TermQuery(new Term(Index.IS_DEFINED_FIELD_NAME, field)), - true, // required - false); - booleanQuery.add(getQuery(), - false, - true); // prohibited + BooleanClause.Occur.MUST); + booleanQuery.add(getQuery(), BooleanClause.Occur.MUST_NOT); setQuery(booleanQuery); } Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/EqExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/EqExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/EqExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/EqExpression.java Wed Feb 21 18:55:26 2007 @@ -23,6 +23,7 @@ package org.apache.slide.index.lucene.expressions; import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.TermQuery; @@ -66,9 +67,9 @@ BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add( new TermQuery(new Term(Index.IS_DEFINED_FIELD_NAME, field)), - true, false); + BooleanClause.Occur.MUST); booleanQuery.add(getQuery(), - false, true); + BooleanClause.Occur.MUST_NOT); setQuery(booleanQuery); } } Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/LikeExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/LikeExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/LikeExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/LikeExpression.java Wed Feb 21 18:55:26 2007 @@ -23,6 +23,7 @@ package org.apache.slide.index.lucene.expressions; import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.PrefixQuery; import org.apache.lucene.search.TermQuery; @@ -68,11 +69,9 @@ BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add( new TermQuery(new Term(Index.IS_DEFINED_FIELD_NAME, field)), - true, // required - false); + BooleanClause.Occur.MUST); booleanQuery.add(getQuery(), - false, - true); // prohibited + BooleanClause.Occur.MUST_NOT); setQuery(booleanQuery); } } Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/MergeExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/MergeExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/MergeExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/MergeExpression.java Wed Feb 21 18:55:26 2007 @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.Query; @@ -65,7 +66,7 @@ Object e = i.next(); AbstractLuceneExpression expression = (AbstractLuceneExpression)e; Query q = expression.getQuery(); - booleanQuery.add(q, and, false); + booleanQuery.add(q, and ? BooleanClause.Occur.MUST : BooleanClause.Occur.SHOULD); } setQuery(booleanQuery); } Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropcontainsExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropcontainsExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropcontainsExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropcontainsExpression.java Wed Feb 21 18:55:26 2007 @@ -23,6 +23,7 @@ package org.apache.slide.index.lucene.expressions; import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.WildcardQuery; @@ -59,11 +60,9 @@ BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add( new TermQuery(new Term(Index.IS_DEFINED_FIELD_NAME, field)), - true, // required - false); + BooleanClause.Occur.MUST); booleanQuery.add(getQuery(), - false, - true); // prohibited + BooleanClause.Occur.MUST_NOT); setQuery(booleanQuery); } } Modified: jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropertyContainsExpression.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropertyContainsExpression.java?view=diff&rev=510360&r1=510359&r2=510360 ============================================================================== --- jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropertyContainsExpression.java (original) +++ jakarta/slide/trunk/src/stores/org/apache/slide/index/lucene/expressions/PropertyContainsExpression.java Wed Feb 21 18:55:26 2007 @@ -29,6 +29,7 @@ import org.apache.lucene.analysis.Token; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.index.Term; +import org.apache.lucene.search.BooleanClause; import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.PhraseQuery; import org.apache.lucene.search.PrefixQuery; @@ -78,11 +79,9 @@ BooleanQuery booleanQuery = new BooleanQuery(); booleanQuery.add( new TermQuery(new Term(Index.IS_DEFINED_FIELD_NAME, field)), - true, // required - false); + BooleanClause.Occur.MUST); booleanQuery.add(getQuery(), - false, - true); // prohibited + BooleanClause.Occur.MUST_NOT); setQuery(booleanQuery); } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]