O'Reilly logo

Mastering Apache Solr 7.x by Dharmesh Vasoya, Chintan Mehta, Sandeep Nair

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How an analyzer works

Text analysis takes place in two phases, during index time and during query time. So we need to configure <analyzer> for both phases, distinguished by the type attribute. In the preceding example, we have configured a single <analyzer> element along with tokenizers and filters and not specified the type attribute. So Solr will apply the same configurations for the both phases (index and query). This type of configuration is required for some scenarios, say if we want to match strings exactly.

It is always advisable to define two separate <analyzer> for each phase distinguished by a type attribute. Doing so is required in some scenarios where we want to apply some steps at query time but not index time. For example:

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required