Stemmer override token filter

Overrides stemming algorithms, by applying a custom mapping, then protecting these terms from being modified by stemmers. Must be placed before any stemming filters.

Rules are mappings in the form of token1[, ..., tokenN] => override.

SettingDescription

rules

A list of mapping rules to use.

rules_path

A path (either relative to config location, or absolute) to a list of mappings.

Here is an example:

  1. PUT /my-index-000001
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "my_analyzer": {
  7. "tokenizer": "standard",
  8. "filter": [ "lowercase", "custom_stems", "porter_stem" ]
  9. }
  10. },
  11. "filter": {
  12. "custom_stems": {
  13. "type": "stemmer_override",
  14. "rules_path": "analysis/stemmer_override.txt"
  15. }
  16. }
  17. }
  18. }
  19. }

Where the file looks like:

  1. running, runs => run
  2. stemmer => stemmer

You can also define the overrides rules inline:

  1. PUT /my-index-000001
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "my_analyzer": {
  7. "tokenizer": "standard",
  8. "filter": [ "lowercase", "custom_stems", "porter_stem" ]
  9. }
  10. },
  11. "filter": {
  12. "custom_stems": {
  13. "type": "stemmer_override",
  14. "rules": [
  15. "running, runs => run",
  16. "stemmer => stemmer"
  17. ]
  18. }
  19. }
  20. }
  21. }
  22. }