Class: Ferret::Analysis::RegExpAnalyzer

Inherits:
Object
  • Object
show all
Defined in:
ext/r_analysis.c

Overview

Summary

Using a RegExpAnalyzer is a simple way to create a custom analyzer. If implemented in Ruby it would look like this;

class RegExpAnalyzer
  def initialize(reg_exp, lower = true)
    @lower = lower
    @reg_exp = reg_exp
  end

  def token_stream(field, str)
    if @lower
      return LowerCaseFilter.new(RegExpTokenizer.new(str, reg_exp))
    else
      return RegExpTokenizer.new(str, reg_exp)
    end
  end
end

Example

csv_analyzer = RegExpAnalyzer.new(/[^,]+/, false)