ReversedWildcardFilterFactory (Solr 3.6.2 API)
Keywords: org.apache.solr.analysis.ReversedWildcardFilterFactory class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.solr.analysis
Class ReversedWildcardFilterFactory

    java.lang.Object
      org.apache.solr.analysis.BaseTokenFilterFactory
          org.apache.solr.analysis.ReversedWildcardFilterFactory

All Implemented Interfaces:
  TokenFilterFactory

    public class ReversedWildcardFilterFactory

extends BaseTokenFilterFactory

Factory for `ReversedWildcardFilter`-s. When this factory is added to an analysis chain, it will be used both for filtering the tokens during indexing, and to determine the query processing of this field during search.

This class supports the following init arguments:

- `withOriginal` - if true, then produce both original and reversed tokens at the same positions. If false, then produce only reversed tokens.
- `maxPosAsterisk` - maximum position (1-based) of the asterisk wildcard ('*') that triggers the reversal of query term. Asterisk that occurs at positions higher than this value will not cause the reversal of query term. Defaults to 2, meaning that asterisks on positions 1 and 2 will cause a reversal.
- `maxPosQuestion` - maximum position (1-based) of the question mark wildcard ('?') that triggers the reversal of query term. Defaults to 1. Set this to 0, and `maxPosAsterisk` to 1 to reverse only pure suffix queries (i.e. ones with a single leading asterisk).
- `maxFractionAsterisk` - additional parameter that triggers the reversal if asterisk ('*') position is less than this fraction of the query token length. Defaults to 0.0f (disabled).
- `minTrailing` - minimum number of trailing characters in query token after the last wildcard character. For good performance this should be set to a value larger than 1. Defaults to 2.

Note 1: This filter always reverses input tokens during indexing. Note 2: Query tokens without wildcard characters will never be reversed.

     <fieldType name="text_rvswc" class="solr.TextField" positionIncrementGap="100">
       <analyzer type="index">
         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
         <filter class="solr.ReversedWildcardFilterFactory" withOriginal="true"
                 maxPosAsterisk="2" maxPosQuestion="1" minTrailing="2" maxFractionAsterisk="0"/>
       </analyzer>
       <analyzer type="query">
         <tokenizer class="solr.WhitespaceTokenizerFactory"/>
       </analyzer>
     </fieldType>

Version:
  $Id$

Field Summary
`protected Map<String,String>` | `args` The init args
`protected Version` | `luceneMatchVersion` the luceneVersion arg

Fields inherited from class org.apache.solr.analysis.BaseTokenFilterFactory
`log`

Constructor Summary
`ReversedWildcardFilterFactory()`

Method Summary
`protected void` | `assureMatchVersion()` this method can be called in the `TokenizerFactory.create(java.io.Reader)` or `TokenFilterFactory.create(org.apache.lucene.analysis.TokenStream)` methods, to inform user, that for this factory a `luceneMatchVersion` is required
`TokenStream` | `create(TokenStream input)` Transform the specified input TokenStream
`Map<String,String>` | `getArgs()`
`protected boolean` | `getBoolean(String name, boolean defaultVal)`
`protected boolean` | `getBoolean(String name, boolean defaultVal, boolean useDefault)`
`protected float` | `getFloat(String name, float defValue)`
`protected int` | `getInt(String name)`
`protected int` | `getInt(String name, int defaultVal)`
`protected int` | `getInt(String name, int defaultVal, boolean useDefault)`
`char` | `getMarkerChar()`
`protected CharArraySet` | `getSnowballWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase)` same as `getWordSet(ResourceLoader, String, boolean)`, except the input is in snowball format.
`protected CharArraySet` | `getWordSet(ResourceLoader loader, String wordFiles, boolean ignoreCase)`
`void` | `init(Map<String,String> args)` `init` will be called just once, immediately after creation.
`boolean` | `shouldReverse(String token)` This method encapsulates the logic that determines whether a query token should be reversed in order to use the reversed terms in the index.
`protected void` | `warnDeprecated(String message)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface org.apache.solr.analysis.TokenFilterFactory
`getArgs`

Field Detail

### args

    protected Map<String,String> args

  The init args

### luceneMatchVersion

    protected Version luceneMatchVersion

  the luceneVersion arg

Constructor Detail

### ReversedWildcardFilterFactory

    public ReversedWildcardFilterFactory()

Method Detail

### init

    public void init(Map<String,String> args)

  Description copied from interface: `TokenFilterFactory`
  `init` will be called just once, immediately after creation.

  The args are user-level initialization parameters that may be specified when declaring the factory in the schema.xml

  Specified by:
    `init` in interface `TokenFilterFactory`

### create

    public TokenStream create(TokenStream input)

  Description copied from interface: `TokenFilterFactory`
  Transform the specified input TokenStream

### shouldReverse

    public boolean shouldReverse(String token)

  This method encapsulates the logic that determines whether a query token should be reversed in order to use the reversed terms in the index.

  Parameters:
    `token` - input token.
  Returns:
    true if input token should be reversed, false otherwise.

### getMarkerChar

    public char getMarkerChar()

### getFloat

    protected float getFloat(String name,
                             float defValue)

### getArgs

    public Map<String,String> getArgs()

### assureMatchVersion

    protected final void assureMatchVersion()

  this method can be called in the `TokenizerFactory.create(java.io.Reader)` or `TokenFilterFactory.create(org.apache.lucene.analysis.TokenStream)` methods, to inform user, that for this factory a `luceneMatchVersion` is required

### warnDeprecated

    protected final void warnDeprecated(String message)

### getInt

    protected int getInt(String name)

### getInt

    protected int getInt(String name,
                         int defaultVal)

### getInt

    protected int getInt(String name,
                         int defaultVal,
                         boolean useDefault)

### getBoolean

    protected boolean getBoolean(String name,
                                 boolean defaultVal)

### getBoolean

    protected boolean getBoolean(String name,
                                 boolean defaultVal,
                                 boolean useDefault)

### getWordSet

    protected CharArraySet getWordSet(ResourceLoader loader,
                                      String wordFiles,
                                      boolean ignoreCase)
                               throws IOException

  Throws:
    `IOException`

### getSnowballWordSet

    protected CharArraySet getSnowballWordSet(ResourceLoader loader,
                                              String wordFiles,
                                              boolean ignoreCase)
                                       throws IOException

  same as `getWordSet(ResourceLoader, String, boolean)`, except the input is in snowball format.

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD