Romanian analyzer

The built-in romanian analyzer can be applied to a text field using the following command:

  1. PUT /romanian-index
  2. {
  3. "mappings": {
  4. "properties": {
  5. "content": {
  6. "type": "text",
  7. "analyzer": "romanian"
  8. }
  9. }
  10. }
  11. }

copy

Stem exclusion

You can use stem_exclusion with this language analyzer using the following command:

  1. PUT index_with_stem_exclusion_romanian_analyzer
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "stem_exclusion_romanian_analyzer": {
  7. "type": "romanian",
  8. "stem_exclusion": ["autoritate", "aprobat"]
  9. }
  10. }
  11. }
  12. }
  13. }

copy

Romanian analyzer internals

The romanian analyzer is built using the following components:

  • Tokenizer: standard

  • Token filters:

    • lowercase
    • stop (Romanian)
    • keyword
    • stemmer (Romanian)

Custom Romanian analyzer

You can create a custom Romanian analyzer using the following command:

  1. PUT /romanian-index
  2. {
  3. "settings": {
  4. "analysis": {
  5. "filter": {
  6. "romanian_stop": {
  7. "type": "stop",
  8. "stopwords": "_romanian_"
  9. },
  10. "romanian_stemmer": {
  11. "type": "stemmer",
  12. "language": "romanian"
  13. },
  14. "romanian_keywords": {
  15. "type": "keyword_marker",
  16. "keywords": []
  17. }
  18. },
  19. "analyzer": {
  20. "romanian_analyzer": {
  21. "type": "custom",
  22. "tokenizer": "standard",
  23. "filter": [
  24. "lowercase",
  25. "romanian_stop",
  26. "romanian_keywords",
  27. "romanian_stemmer"
  28. ]
  29. }
  30. }
  31. }
  32. },
  33. "mappings": {
  34. "properties": {
  35. "content": {
  36. "type": "text",
  37. "analyzer": "romanian_analyzer"
  38. }
  39. }
  40. }
  41. }

copy

Generated tokens

Use the following request to examine the tokens generated using the analyzer:

  1. POST /romanian-index/_analyze
  2. {
  3. "field": "content",
  4. "text": "Studenții învață la universitățile din România. Numerele lor sunt 123456."
  5. }

copy

The response contains the generated tokens:

  1. {
  2. "tokens": [
  3. {
  4. "token": "studenț",
  5. "start_offset": 0,
  6. "end_offset": 9,
  7. "type": "<ALPHANUM>",
  8. "position": 0
  9. },
  10. {
  11. "token": "învaț",
  12. "start_offset": 10,
  13. "end_offset": 16,
  14. "type": "<ALPHANUM>",
  15. "position": 1
  16. },
  17. {
  18. "token": "universităț",
  19. "start_offset": 20,
  20. "end_offset": 34,
  21. "type": "<ALPHANUM>",
  22. "position": 3
  23. },
  24. {
  25. "token": "român",
  26. "start_offset": 39,
  27. "end_offset": 46,
  28. "type": "<ALPHANUM>",
  29. "position": 5
  30. },
  31. {
  32. "token": "numer",
  33. "start_offset": 48,
  34. "end_offset": 56,
  35. "type": "<ALPHANUM>",
  36. "position": 6
  37. },
  38. {
  39. "token": "123456",
  40. "start_offset": 66,
  41. "end_offset": 72,
  42. "type": "<NUM>",
  43. "position": 9
  44. }
  45. ]
  46. }