1

For example: I want to search "support", I hope it will only return the results containing "support", and do NOT return the result containing "supports" or any other relevant matches.

Is it possible to implement like this?

Thanks.

James Tang
  • 593
  • 6
  • 13

2 Answers2

7

Yes, if you search against an unanalyzed field type, matches are exact. In the default Solr schema the unanalyzed field type is named "string" (of class "solr.StrField")

EDIT: it depends on what you mean by "precisely". If your field value is "support desk" and your query is "support", should it match?

  • If your answer is yes, then you should look into configuring stemming.
  • If your answer is no, i.e. the query must match the field value and nothing else, then you should use a string (i.e. unanalyzed) field type.

Furthermore, if your query is "supports" and the field value is "Supports", should it match?

  • If you answer yes, then you should use a LowerCaseFilterFactory (you can't do this on a string field type, you'll have to switch to a text field type).
  • If you answer no, then it's ok to use a string field type.

In summary, the Lucene/Solr text analysis pipeline is very configurable, take a look at the analyzer docs for a reference of all available options.

Mauricio Scheffer
  • 98,863
  • 23
  • 192
  • 275
3

What you are describing is called stemming. There is another almost identical question on stack overflow, check it out : Solr exact word search You will need to re-index and disable stemming in your configuration. I don't believe it's possible to do that at query time since what is stored in your index is the stemmed version of the word. In your case "support" is stored in the index even is "supports" is displayed. This should get you started How to configure stemming in Solr?

Community
  • 1
  • 1
Edouard Tabet
  • 158
  • 1
  • 10
  • 2
    It depends on what the OP means by "precisely". It's not necessarily about stemming only. – Mauricio Scheffer Nov 24 '11 at 13:35
  • 3
    You're right and I think your answer complements mine. Other transformations are happening, I was just giving the solution for the example. Synonyms, stop words, lowercasing and more can also be configured. What I think is important, is for solr users to discover the configuration file and how configurable everything is. – Edouard Tabet Nov 24 '11 at 20:05
  • I thought it was only about stemming. I get nervous about the aggressiveness of the *default* stemmer. It finds the same root for both "organism" and "organization". Both answers make up the solution. – Jesvin Jose Nov 25 '11 at 17:22