Class: Ferret::Analysis::PerFieldAnalyzer
- Inherits:
-
Analyzer
- Object
- Analyzer
- Ferret::Analysis::PerFieldAnalyzer
- Defined in:
- lib/acts_as_ferret/ferret_extensions.rb
Overview
PerFieldAnalyzer
This PerFieldAnalyzer is a workaround to a memory leak in ferret 0.11.4. It does basically do the same as the original Ferret::Analysis::PerFieldAnalyzer, but without the leak :)
ferret.davebalmain.com/api/classes/Ferret/Analysis/PerFieldAnalyzer.html
Thanks to Ben from omdb.org for tracking this down and creating this workaround. You can read more about the issue there: blog.omdb-beta.org/2007/7/29/tracking-down-a-memory-leak-in-ferret-0-11-4
Instance Method Summary collapse
- #add_field(field, analyzer) ⇒ Object (also: #[]=)
-
#initialize(default_analyzer = StandardAnalyzer.new) ⇒ PerFieldAnalyzer
constructor
A new instance of PerFieldAnalyzer.
- #token_stream(field, string) ⇒ Object
Constructor Details
#initialize(default_analyzer = StandardAnalyzer.new) ⇒ PerFieldAnalyzer
Returns a new instance of PerFieldAnalyzer.
18 19 20 21 |
# File 'lib/acts_as_ferret/ferret_extensions.rb', line 18 def initialize( default_analyzer = StandardAnalyzer.new ) @analyzers = {} @default_analyzer = default_analyzer end |
Instance Method Details
#add_field(field, analyzer) ⇒ Object Also known as: []=
23 24 25 |
# File 'lib/acts_as_ferret/ferret_extensions.rb', line 23 def add_field( field, analyzer ) @analyzers[field] = analyzer end |
#token_stream(field, string) ⇒ Object
28 29 30 31 |
# File 'lib/acts_as_ferret/ferret_extensions.rb', line 28 def token_stream(field, string) @analyzers.has_key?(field) ? @analyzers[field].token_stream(field, string) : @default_analyzer.token_stream(field, string) end |