Search code examples
solrstemming

Default english stemming in SOLR


I'm trying to do simple english words stemming in SOLR, but for some reason I'm not successful.

my xml doc looks like this:

<add><doc>
  <str name="id">1</str>
  <str name="name">walked</str>
</doc>
<doc>
  <str name="id">2</str>
  <str name="name">walking</str>
</doc>
<doc>
  <str name="id">3</str>
  <str name="name">walks</str>
</doc>
</add>

in schema XML I change name type to "text_en"

<field name="name" type="text_en" indexed="true" stored="true"/>

I don't change anything else and I think it should work (I tried everything: creating new fields and new fieldTypes for them according to various tutorials and so on, but something goes wrong and I don't know what)

One more point if I try to anlyse these words in analysis section in SOLR (http://localhost:8983/solr/#/collection1/analysis) It works fine.

For example:

Field Value(index) and Field Value(query) I input value: walking. Text field in PorterStemFilter section equals "walk" as I wish.

But when I do query walking in query section it matches 0 values! I want it to match all values (walking, walked, walks) query url: http://localhost:8983/solr/collection1/select?q=*walking*&wt=json&indent=true

EDIT

P.S. I reindexed this many times, it can't be a problem.

EDIT #2

Thank you very much. Now everything is clear. I will explain what I undestood today, maybe it will be useful for someone.

If your url is like this

http://localhost:8983/solr/collection1/select?q=walking&wt=json&indent=true

You are using field: "text" (default field is text), because there isn't specified field in query.

 <field name="text" type="text_en" indexed="true" stored="false" multiValued="true"/>

If you want to stem specific field not "text", you have to specify it in url. For example field "name":

http://localhost:8983/solr/collection1/select?q=name:walking&wt=json&indent=true

one more point not to forget. field property "indexed" which you want to stem must be set to "true". Thanks for help!


Solution

  • Your query doesn't look right, try to query it like this:

    http://localhost:8983/solr/collection1/select?q=name:walking&wt=json&indent=true