To edit pages or tickets please login with username/password: aaf/aaf

Ticket #189 (closed enhancement: fixed)

Opened 10 months ago

Last modified 8 months ago

[PATCH] Allow for per-document analyzers.

Reported by: aaf Assigned to: jk
Priority: major Milestone:
Component: 0plugin Version:
Keywords: patch Cc:

Description

This may be useful, for example, in the case of documents being in different languages.

Ferret defines add_document(doc, analyzer = nil) method, so, your ferret_create (et. al.) method could have instead of

self.class.aaf_index << self

something like this

self.class.aaf_index.add_document(self, ferret_analyzer)

where ferret_analyzer is a hypothetical instance method on a model returning suitable analyzer based, say, on models's language. Or its name might be configured through options to acts_as_ferret method or using procs or whatever, it's certainly up to you. Thanks.

Attachments

aaf_patch_189.diff (1.7 kB) - added by aaf on 01/15/08 08:31:33.

Change History

01/13/08 03:44:53 changed by aaf

  • keywords set to patch.
  • priority changed from minor to major.
  • summary changed from Allow for per-document analyzers. to [PATCH] Allow for per-document analyzers..

ok, i'm a patch maniac today. +1 for this ticket. please see the patch. used this way:

  acts_as_ferret :fields => {
    :title => {...},
    :text => {...},
    :instance_analyzer => :analyzer
    :remote => false,
    :index_dir => "#{RAILS_ROOT}/db/index/#{RAILS_ENV}/job",
    :ferret => {:analyzer => anal}

  def analyzer
    case somecondition
      ......
    else
      nil # use default
    end
  end

01/15/08 08:31:33 changed by aaf

  • attachment aaf_patch_189.diff added.

02/02/08 12:34:39 changed by jk

  • status changed from new to closed.
  • resolution set to fixed.

implemented in trunk now.

However I chose a (imho) simpler solution: Aaf now declares a method named ferret_analyzer which by default returns nil and may be overridden in model classes to return the custom analyzer for this record.

To edit pages or tickets please login with username/password: aaf/aaf