mirror of https://github.com/apache/lucene.git
LUCENE-3549: port to trunk
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1196474 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ca0aa9f80
commit
145d7503a3
|
@ -14,7 +14,6 @@ import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
|
||||
import org.apache.lucene.DocumentBuilder;
|
||||
import org.apache.lucene.facet.example.ExampleUtils;
|
||||
import org.apache.lucene.facet.example.simple.SimpleUtils;
|
||||
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
|
||||
|
@ -167,7 +166,7 @@ public class MultiCLIndexer {
|
|||
// we do not alter indexing parameters!
|
||||
// a category document builder will add the categories to a document
|
||||
// once build() is called
|
||||
DocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(
|
||||
CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(
|
||||
taxo, iParams).setCategoryPaths(facetList);
|
||||
|
||||
// create a plain Lucene document and add some regular Lucene fields
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.apache.lucene.index.IndexWriterConfig;
|
|||
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
|
||||
import org.apache.lucene.store.Directory;
|
||||
|
||||
import org.apache.lucene.DocumentBuilder;
|
||||
import org.apache.lucene.facet.example.ExampleUtils;
|
||||
import org.apache.lucene.facet.index.CategoryDocumentBuilder;
|
||||
import org.apache.lucene.facet.taxonomy.CategoryPath;
|
||||
|
@ -66,7 +65,7 @@ public class SimpleIndexer {
|
|||
|
||||
// we do not alter indexing parameters!
|
||||
// a category document builder will add the categories to a document once build() is called
|
||||
DocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxo).setCategoryPaths(facetList);
|
||||
CategoryDocumentBuilder categoryDocBuilder = new CategoryDocumentBuilder(taxo).setCategoryPaths(facetList);
|
||||
|
||||
// create a plain Lucene document and add some regular Lucene fields to it
|
||||
Document doc = new Document();
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
package org.apache.lucene;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* An interface which standardizes the process of building an indexable
|
||||
* {@link Document}.
|
||||
* <p>
|
||||
* The idea is that implementations implement {@link #build(Document doc)},
|
||||
* which adds to the given Document whatever {@link Field}s it wants to add. A
|
||||
* DocumentBuilder is also allowed to inspect or change existing Fields in the
|
||||
* Document, if it wishes to.
|
||||
* <p>
|
||||
* Implementations should normally have a constructor with parameters which
|
||||
* determine what {@link #build(Document)} will add to doc.<br>
|
||||
* To allow reuse of the DocumentBuilder object, implementations are also
|
||||
* encouraged to have a setter method, which remembers its parameters just like
|
||||
* the constructor. This setter method cannot be described in this interface,
|
||||
* because it will take different parameters in each implementation.
|
||||
* <p>
|
||||
* The interface defines a builder pattern, which allows applications to invoke
|
||||
* several document builders in the following way:
|
||||
*
|
||||
* <pre>
|
||||
* builder1.build(builder2.build(builder3.build(new Document())));
|
||||
* </pre>
|
||||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public interface DocumentBuilder {
|
||||
|
||||
/** An exception thrown from {@link DocumentBuilder}'s build(). */
|
||||
public static class DocumentBuilderException extends Exception {
|
||||
|
||||
public DocumentBuilderException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DocumentBuilderException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DocumentBuilderException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DocumentBuilderException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds to the given document whatever {@link Field}s the implementation needs
|
||||
* to add. Return the docunment instance to allow for chaining calls.
|
||||
*/
|
||||
public Document build(Document doc) throws DocumentBuilderException;
|
||||
|
||||
}
|
|
@ -13,7 +13,6 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.document.FieldType;
|
||||
import org.apache.lucene.document.TextField;
|
||||
|
||||
import org.apache.lucene.DocumentBuilder;
|
||||
import org.apache.lucene.facet.index.attributes.CategoryAttribute;
|
||||
import org.apache.lucene.facet.index.attributes.CategoryAttributesIterable;
|
||||
import org.apache.lucene.facet.index.categorypolicy.OrdinalPolicy;
|
||||
|
@ -64,7 +63,7 @@ import org.apache.lucene.facet.taxonomy.TaxonomyWriter;
|
|||
*
|
||||
* @lucene.experimental
|
||||
*/
|
||||
public class CategoryDocumentBuilder implements DocumentBuilder {
|
||||
public class CategoryDocumentBuilder {
|
||||
|
||||
/**
|
||||
* A {@link TaxonomyWriter} for adding categories and retrieving their
|
||||
|
@ -288,9 +287,7 @@ public class CategoryDocumentBuilder implements DocumentBuilder {
|
|||
return new CategoryTokenizer(categoryStream, indexingParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the fields created in one of the "set" methods to the document
|
||||
*/
|
||||
/** Adds the fields created in one of the "set" methods to the document */
|
||||
public Document build(Document doc) {
|
||||
for (Field f : fieldList) {
|
||||
doc.add(f);
|
||||
|
|
|
@ -9,7 +9,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.lucene.DocumentBuilder.DocumentBuilderException;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.MockAnalyzer;
|
||||
import org.apache.lucene.analysis.MockTokenizer;
|
||||
|
@ -191,7 +190,7 @@ public abstract class FacetTestBase extends LuceneTestCase {
|
|||
* <p>Subclasses can override this to test different scenarios
|
||||
*/
|
||||
protected void populateIndex(RandomIndexWriter iw, TaxonomyWriter taxo, FacetIndexingParams iParams)
|
||||
throws IOException, DocumentBuilderException, CorruptIndexException {
|
||||
throws IOException, CorruptIndexException {
|
||||
// add test documents
|
||||
int numDocsToIndex = numDocsToIndex();
|
||||
for (int doc=0; doc<numDocsToIndex; doc++) {
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.IOException;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.lucene.DocumentBuilder.DocumentBuilderException;
|
||||
import org.apache.lucene.index.CorruptIndexException;
|
||||
import org.apache.lucene.index.IndexWriterConfig;
|
||||
import org.apache.lucene.index.RandomIndexWriter;
|
||||
|
@ -52,8 +51,7 @@ public abstract class BaseTestTopK extends FacetTestBase {
|
|||
|
||||
@Override
|
||||
protected void populateIndex(RandomIndexWriter iw, TaxonomyWriter taxo,
|
||||
FacetIndexingParams iParams) throws IOException,
|
||||
DocumentBuilderException, CorruptIndexException {
|
||||
FacetIndexingParams iParams) throws IOException, CorruptIndexException {
|
||||
currDoc = -1;
|
||||
super.populateIndex(iw, taxo, iParams);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue