Displaying 1 result from an estimated 1 matches for "suggestion_index".
2006 Oct 05
4
search results autocompletion
...ll the terms belonging to
other indices. Here is the code:
class Suggestion
attr_accessor :term
def self.index(create)
[Person, Project, Orgunit].each{|kl|
terms = self.all_terms(kl)
terms.each{|term|
suggestion = Suggestion.new
suggestion.term = term
SUGGESTION_INDEX << suggestion.to_doc
}
}
SUGGESTION_INDEX.optimize
end
def self.all_terms(klass)
reader = Index::IndexReader.new(Object.const_get(klass.name.upcase +
"_INDEX_DIR"))
terms = []
begin
reader.field_names.each {|field_name|
term_enum = reader.term...