开发者

Adding stemming to my schema.xml file doesn't work

开发者 https://www.devze.com 2023-02-16 23:47 出处:网络
I\'m trying to setup Websolr on my Heroku app. I\'m following the instructions in the Heroku docs. I\'ve got the initial setup working fine.

I'm trying to setup Websolr on my Heroku app. I'm following the instructions in the Heroku docs. I've got the initial setup working fine.

In development:

ru开发者_C百科by-1.9.2-p0 > Note.search { keywords 'grit' }.results.length
 => 3

I am trying to add stemming. I updated the relevant part of my schema.xml file to this:

<fieldType name="text" class="solr.TextField" omitNorms="false">

  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>
  <analyzer type="index">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StandardFilterFactory"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.PorterStemFilterFactory"/>
  </analyzer>

</fieldType>

I then reindexed:

$ rake sunspot:reindex

But it doesn't seem to work at all:

ruby-1.9.2-p0 > Note.search { keywords 'gri' }.results.length
 => 0

What am I doing wrong?


I have two ideas for you here:

Firstly, you didn't mention whether you were restarting Solr after changing your schema.xml. So: are you restarting Solr so your changes can take effect? :)

Next, I am wondering if the term grit would even qualify to have its t removed under the Porter stemming algorithm. You would need to have a close read of the PorterStemmer algorithm to be sure. But you may also try some more obvious examples (say, writing to write).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号