Class | Ferret::Analysis::PerFieldAnalyzer
In: | ext/r_analysis.c
Parent: | Ferret::Analysis::Analyzer

## Summary

The PerFieldAnalyzer is for use when you want to analyze different fields with different analyzers. With the PerFieldAnalyzer you can specify how you want each field analyzed.

### Example

      # Create a new PerFieldAnalyzer which uses StandardAnalyzer by default
      pfa = PerFieldAnalyzer.new(StandardAnalyzer.new())

      # Use the WhiteSpaceAnalyzer with no lowercasing on the :title field
      pfa[:title] = WhiteSpaceAnalyzer.new(false)

      # Use a custom analyzer on the :created_at field
      pfa[:created_at] = DateAnalyzer.new

### Methods

[]= add_field new token_stream

### Public Class methods

PerFieldAnalyzer.new(default_analyzer) → analyzer

Create a new PerFieldAnalyzer specifying the default analyzer to use on all fields that are set specifically.

default_analyzer: | analyzer to be used on fields that aren‘t otherwise specified

### Public Instance methods

per_field_analyzer.add_field(field_name, default_analyzer) → self
per_field_analyzer[field_name] = default_analyzer → self

Set the analyzer to be used on field `field_name`. Note that field_name should be a symbol.

field_name: | field we wish to set the analyzer for
analyzer: | analyzer to be used on `field_name`

per_field_analyzer.add_field(field_name, default_analyzer) → self
per_field_analyzer[field_name] = default_analyzer → self

Set the analyzer to be used on field `field_name`. Note that field_name should be a symbol.

field_name: | field we wish to set the analyzer for
analyzer: | analyzer to be used on `field_name`

analyzer.token_stream(field_name, input) → token_stream

Create a new TokenStream to tokenize `input`. The TokenStream created will also depend on the `field_name` in the case of the PerFieldAnalyzer.

field_name: | name of the field to be tokenized
input: | data from the field to be tokenized

[Validate]