Forum: Ferret Ferret wildcard search

B72a84452a5b54f1e1024f7ce16f6e11?d=identicon&s=25 Joachim Schneider (joschy)
on 2008-08-20 12:06
Hello community,

using ferret 0.11.5 under Win2003 Server i got the following error:

Searching: "Zürich" works fine
Searching: "Zuerich*" works fine
Searching: "Zürich*" returns 0 results

Every "Umlaut" like "üä" including a wildcard leads to zero results.

I am exporting data from an UTF8 database to a ferret index. Everything
works fine, except the shown problem. Tried also different
Ferret.locales - same result.

Thank you very much for every help,
Joschy





require 'ferret'
require 'active_record'
require 'yaml'
require 'iconv'
include Ferret

class User < ActiveRecord::Base
end


#database with UTF8-general, search user
db_config =
YAML::load(File.open("D:/XamppApps/Project.AddressBook/AddressBookWeb/config/database.yml"))
ActiveRecord::Base.establish_connection(db_config["service"])
user = User.find(:first, :conditions => ['uid= ?', 'jschneid'])


#create new ferret index
field_infos = Index::FieldInfos.new()
field_infos.create_index("D:/XamppApps/Project.AddressBook/AddressBookWeb/index2")


#create new ferret index
ferret_configuration = {
            :path =>
"D:/XamppApps/Project.AddressBook/AddressBookWeb/index2",
            :handle_parse_errors => true,
            :default_search_field => '*',
      :analyzer => Analysis::StandardAnalyzer.new,
            :wild_lower => true
}

index = Index::Index.new(ferret_configuration)



#update index
doc = Hash.new(user.id)
doc['city'] = user.city
doc['uid'] = user.uid

index << doc
index.flush



#result: OK
value = "Zürich"
value = Iconv.conv('utf-8', 'ISO-8859-1', value)
puts (index.search(value).total_hits)


#result: 0 -> error
value = "Zürich*"
value = Iconv.conv('utf-8', 'ISO-8859-1', value)
puts (index.search(value).total_hits)
This topic is locked and can not be replied to.