NGramFilterFactory and Phrase

190 Views Asked by At

I'm using the NGramFilterFactory in Schema.xml. But when searching a (correct) phrase im getting no results. Is there an option to solve this problem?

A book has a title: Multi-strange baryon production at mid-rapidity.
I'm getting an result when searching for:

Multi-strange baryon

but when searching a phrase:

"Multi-strange baryon"

im getting no results.

Schema.xml

<fieldType name="ngram" class="solr.TextField" omitNorms="false">
 <analyzer type="index">
  <tokenizer class="solr.WhitespaceTokenizerFactory"/>                     
  <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
  <filter class="solr.LowerCaseFilterFactory"/>
  <filter class="solr.NGramFilterFactory" minGramSize="3" maxGramSize="50"/>
 </analyzer>
 <analyzer type="query">
   <tokenizer class="solr.WhitespaceTokenizerFactory"/>
   <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt"/>
   <filter class="solr.LowerCaseFilterFactory"/>
 </analyzer>
</fieldType>

...

<dynamicField name="*_ngram" stored="false" type="ngram" multiValued="true" indexed="true"/>

Book.rb

class Book < ActiveRecord::Base
  attr_accessible :authors, :title

  searchable do    
    text :title, :as => :ngram
  end    
end

BooksController.rb

  def search
    @books = Sunspot.search([Book]) do
      keywords params[:query]
    end.results

    respond_to do |format|
      format.html { render :action => "index" }
      format.xml  { render :xml => @books }
    end
  end
0

There are 0 best solutions below