Skip to content

Commit

Permalink
LUCENE-8778: Define analyzer SPI names as static final fields and doc…
Browse files Browse the repository at this point in the history
…ument the names in all analysis components. This also changes SPI loader to detect service names via the static NAME fields instead of class names.
  • Loading branch information
mocobeta committed Jun 22, 2019
1 parent 54cc701 commit 98c85a0
Show file tree
Hide file tree
Showing 159 changed files with 750 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ pom.xml
.pydevproject
__pycache__
/dev-tools/scripts/scripts.iml

2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Bug fixes
Other

* LUCENE-8768: Fix Javadocs build in Java 11. (Namgyu Kim)
* LUCENE-8778: Define analyzer SPI names as static final fields and document the names in Javadocs.
(Tomoko Uchida, Uwe Schindler)

======================= Lucene 8.2.0 =======================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class ArabicNormalizationFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "arabicNormalization";

/** Creates a new ArabicNormalizationFilterFactory */
public ArabicNormalizationFilterFactory(Map<String,String> args) {
super(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class ArabicStemFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "arabicStem";

/** Creates a new ArabicStemFilterFactory */
public ArabicStemFilterFactory(Map<String,String> args) {
super(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 3.1.0
* @lucene.spi {@value #NAME}
*/
public class BulgarianStemFilterFactory extends TokenFilterFactory {


/** SPI name */
public static final String NAME = "bulgarianStem";

/** Creates a new BulgarianStemFilterFactory */
public BulgarianStemFilterFactory(Map<String,String> args) {
super(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 7.1.0
* @lucene.spi {@value #NAME}
*/
public class BengaliNormalizationFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "bengaliNormalization";

public BengaliNormalizationFilterFactory(Map<String,String> args) {
super(args);
if (!args.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 7.1.0
* @lucene.spi {@value #NAME}
*/
public class BengaliStemFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "bengaliStem";

public BengaliStemFilterFactory(Map<String,String> args) {
super(args);
if (!args.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class BrazilianStemFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "brazilianStem";

/** Creates a new BrazilianStemFilterFactory */
public BrazilianStemFilterFactory(Map<String,String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class HTMLStripCharFilterFactory extends CharFilterFactory {

/** SPI name */
public static final String NAME = "htmlStrip";

final Set<String> escapedTags;
static final Pattern TAG_NAME_PATTERN = Pattern.compile("[^\\s,]+");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@
* &lt;/fieldType&gt;</pre>
*
* @since Solr 1.4
* @lucene.spi {@value #NAME}
*/
public class MappingCharFilterFactory extends CharFilterFactory implements
ResourceLoaderAware {

/** SPI name */
public static final String NAME = "mapping";

protected NormalizeCharMap normMap;
private final String mapping;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,13 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 3.6.0
* @lucene.spi {@value #NAME}
*/
public class CJKBigramFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "cjkBigram";

final int flags;
final boolean outputUnigrams;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 3.6.0
* @lucene.spi {@value #NAME}
*/
public class CJKWidthFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "cjkWidth";

/** Creates a new CJKWidthFilterFactory */
public CJKWidthFilterFactory(Map<String,String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 4.7.0
* @lucene.spi {@value #NAME}
*/
public class SoraniNormalizationFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "soraniNormalization";

/** Creates a new SoraniNormalizationFilterFactory */
public SoraniNormalizationFilterFactory(Map<String,String> args) {
super(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 4.7.0
* @lucene.spi {@value #NAME}
*/
public class SoraniStemFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "soraniStem";

/** Creates a new SoraniStemFilterFactory */
public SoraniStemFilterFactory(Map<String,String> args) {
super(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class CommonGramsFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {
// TODO: shared base class for Stop/Keep/CommonGrams?

/** SPI name */
public static final String NAME = "commonGrams";

// TODO: shared base class for Stop/Keep/CommonGrams?
private CharArraySet commonWords;
private final String commonWordFiles;
private final String format;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class CommonGramsQueryFilterFactory extends CommonGramsFilterFactory {

public static final String NAME = "commonGramsQuery";

/** Creates a new CommonGramsQueryFilterFactory */
public CommonGramsQueryFilterFactory(Map<String,String> args) {
super(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class DictionaryCompoundWordTokenFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {

/** SPI name */
public static final String NAME = "dictionaryCompoundWord";

private CharArraySet dictionary;
private final String dictFile;
private final int minWordSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@
*
* @see HyphenationCompoundWordTokenFilter
* @since 3.1.0
* @lucene.spi {@value #NAME}
*/
public class HyphenationCompoundWordTokenFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {

/** SPI name */
public static final String NAME = "hyphenationCompoundWord";

private CharArraySet dictionary;
private HyphenationTree hyphenator;
private final String dictFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 5.4.0
* @lucene.spi {@value #NAME}
*/
public class DecimalDigitFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "decimalDigit";

/** Creates a new DecimalDigitFilterFactory */
public DecimalDigitFilterFactory(Map<String,String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@
*
* @lucene.experimental
* @since 6.4.0
* @lucene.spi {@value #NAME}
*/
public class FlattenGraphFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "flattenGraph";

/** Creates a new FlattenGraphFilterFactory */
public FlattenGraphFilterFactory(Map<String,String> args) {
super(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@
* </ul>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class KeywordTokenizerFactory extends TokenizerFactory {

/** SPI name */
public static final String NAME = "keyword";

private final int maxTokenLen;

/** Creates a new KeywordTokenizerFactory */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@
* </ul>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class LetterTokenizerFactory extends TokenizerFactory {

/** SPI name */
public static final String NAME = "letter";

private final int maxTokenLen;

/** Creates a new LetterTokenizerFactory */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
* &lt;/fieldType&gt;</pre>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class LowerCaseFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "lowercase";

/** Creates a new LowerCaseFilterFactory */
public LowerCaseFilterFactory(Map<String,String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@
* </ul>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class StopFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {

/** SPI name */
public static final String NAME = "stop";

public static final String FORMAT_WORDSET = "wordset";
public static final String FORMAT_SNOWBALL = "snowball";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,13 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 3.6.0
* @lucene.spi {@value #NAME}
*/
public class TypeTokenFilterFactory extends TokenFilterFactory implements ResourceLoaderAware {

/** SPI name */
public static final String NAME = "type";

private final boolean useWhitelist;
private final String stopTypesFiles;
private Set<String> stopTypes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@
* when you require uppercase tokens. Use the {@link LowerCaseFilterFactory} for
* general search matching
* @since 4.7.0
* @lucene.spi {@value #NAME}
*/
public class UpperCaseFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "uppercase";

/** Creates a new UpperCaseFilterFactory */
public UpperCaseFilterFactory(Map<String,String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@
* </ul>
*
* @since 3.1
* @lucene.spi {@value #NAME}
*/
public class WhitespaceTokenizerFactory extends TokenizerFactory {

/** SPI name */
public static final String NAME = "whitespace";

public static final String RULE_JAVA = "java";
public static final String RULE_UNICODE = "unicode";
private static final Collection<String> RULE_NAMES = Arrays.asList(RULE_JAVA, RULE_UNICODE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 3.1.0
* @lucene.spi {@value #NAME}
*/
public class CzechStemFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "czechStem";

/** Creates a new CzechStemFilterFactory */
public CzechStemFilterFactory(Map<String,String> args) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,12 @@
* &lt;/analyzer&gt;
* &lt;/fieldType&gt;</pre>
* @since 3.1.0
* @lucene.spi {@value #NAME}
*/
public class GermanLightStemFilterFactory extends TokenFilterFactory {

/** SPI name */
public static final String NAME = "germanLightStem";

/** Creates a new GermanLightStemFilterFactory */
public GermanLightStemFilterFactory(Map<String,String> args) {
Expand Down
Loading

0 comments on commit 98c85a0

Please sign in to comment.