To bring the LIA code examples up to date with Lucene 2.x API there are only a few minor changes necessary: Replace all BooleanQuery.add's, e.g.:
- subjectQuery.add(tq, false, false); + subjectQuery.add(tq, BooleanClause.Occur.SHOULD);
Substitute RangeFilter for DateFilter usage, e.g.:
- DateFilter filter = new DateFilter("modified", jan1, dec31); + RangeFilter filter = new RangeFilter("modified", jan1, dec31, true, true);
NOTE: The dates are now String's generated by DateUtils.dateToString() and incompatible with DateField Replace all Field.Keyword/UnStored/Text/UnIndexed with the enumerated types, e.g.:
- doc.add(Field.Keyword("animal", animal)); + doc.add(new Field("animal", animal, Field.Store.YES, Field.Index.UN_TOKENIZED));
Rename PhrasePrefixQuery -> MultiPhraseQuery
Use instance of QueryParser instead of static parse method, e.g.:
- Query query = QueryParser.parse(expression, "contents", analyzer); + Query query = new QueryParser("contents", analyzer).parse(expression)
QueryParser subclasses adjusted for overridden getXXXQuery method signatures.
IndexReader.
delete() updated to be
IndexReader.deleteDocument/.deleteDocuments()
IndexWriter internal configuration values now accessed through getters/setters rather than the fields directly, with minMergeDocs renamed as setMaxBufferedDocs().
QueryParser.setLowercaseWildcardTerms() replaced with .setLowercaseExpandedTerms()
QueryParser.getRangeQuery() still uses DateField when constructing a RangeQuery. If your index is built using DateTools, you will need to subclass and override, as shown in QueryParserTest.testRangeQuery(). [Permalink]