1 package org.apache.lucene.search.vectorhighlight;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.io.IOException;
22 import org.apache.lucene.index.IndexReader;
23 import org.apache.lucene.search.highlight.Encoder;
26 * {@link org.apache.lucene.search.vectorhighlight.FragmentsBuilder} is an interface for fragments (snippets) builder classes.
27 * A {@link org.apache.lucene.search.vectorhighlight.FragmentsBuilder} class can be plugged in to
28 * {@link org.apache.lucene.search.vectorhighlight.FastVectorHighlighter}.
30 public interface FragmentsBuilder {
35 * @param reader IndexReader of the index
36 * @param docId document id to be highlighted
37 * @param fieldName field of the document to be highlighted
38 * @param fieldFragList FieldFragList object
39 * @return a created fragment or null when no fragment created
42 public String createFragment( IndexReader reader, int docId, String fieldName,
43 FieldFragList fieldFragList ) throws IOException;
46 * create multiple fragments.
48 * @param reader IndexReader of the index
49 * @param docId document id to be highlighter
50 * @param fieldName field of the document to be highlighted
51 * @param fieldFragList FieldFragList object
52 * @param maxNumFragments maximum number of fragments
53 * @return created fragments or null when no fragments created.
54 * size of the array can be less than maxNumFragments
57 public String[] createFragments( IndexReader reader, int docId, String fieldName,
58 FieldFragList fieldFragList, int maxNumFragments ) throws IOException;
63 * @param reader IndexReader of the index
64 * @param docId document id to be highlighted
65 * @param fieldName field of the document to be highlighted
66 * @param fieldFragList FieldFragList object
67 * @param preTags pre-tags to be used to highlight terms
68 * @param postTags post-tags to be used to highlight terms
69 * @param encoder an encoder that generates encoded text
70 * @return a created fragment or null when no fragment created
73 public String createFragment( IndexReader reader, int docId, String fieldName,
74 FieldFragList fieldFragList, String[] preTags, String[] postTags,
75 Encoder encoder ) throws IOException;
78 * create multiple fragments.
80 * @param reader IndexReader of the index
81 * @param docId document id to be highlighter
82 * @param fieldName field of the document to be highlighted
83 * @param fieldFragList FieldFragList object
84 * @param maxNumFragments maximum number of fragments
85 * @param preTags pre-tags to be used to highlight terms
86 * @param postTags post-tags to be used to highlight terms
87 * @param encoder an encoder that generates encoded text
88 * @return created fragments or null when no fragments created.
89 * size of the array can be less than maxNumFragments
92 public String[] createFragments( IndexReader reader, int docId, String fieldName,
93 FieldFragList fieldFragList, int maxNumFragments, String[] preTags, String[] postTags,
94 Encoder encoder ) throws IOException;