> On Tue, Oct 31, 2006 at 03:55:07PM +0900, Jeffrey Gelens wrote: > > I just started using Ferret and I successfully indexed some > documents. I > > can search this index using the following code: > > > > index = Index::Index.new(:path => path) > > index.search_each("something") do |doc, score| > > print "##{doc} #{index[doc]['url']} - #{score}" > > print "\n" > > end > > > > However, when I try to use Search::Searcher and QueryParser I don't > get > > any results. I tried the following code: > > > > queryparser = QueryParser.new() > > searcher = Searcher.new(path) > > queryparser.fields = searcher.reader.fields > > searcher.search(queryparser.parse("something")) > > > > I index all my documents as follows: > > > > index = Index::Index.new(:path => path, :analyzer => > > Analysis::RegExpAnalyzer.new(/./, false)) > > index << { :title => title, :url => link, :body => page } > > > > What am I doing wrong? > > Basically you should use the same analyzer to analyze queries as you > used to analyze your content. So constructing your queryparser like > this: > qp = QueryParser.new(:analyzer => Analysis::RegExpAnalyzer.new(/./, > false)) > your searches should work. > > However, your regexp for the analyzer looks strange - /./ matches > every > single character, including whitespace. So each field's value would be > indexed as 1-character long terms, which probably is not what you > want. > > However I don't know why searching through the Index class worked, > I'd > suspect it not to work, too. > > > Jens
Now I constructed the queryparser using the same analyzer and it seems that was indeed the problem. Thanks. The reason why I'm using the regexp /./ is that I'm indexing Japanese sites. I found a solution on this mailinglist to use a RegExpAnalyzer using this regexp for asian characters. It is working fine. Am I using it correctly or should I index Japanese characters ? -- Jeffrey Gelens _______________________________________________ Ferret-talk mailing list Ferret-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/ferret-talk