Bulgarian analyzer

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

  1. PUT /bulgarian-index
  2. {
  3. "mappings": {
  4. "properties": {
  5. "content": {
  6. "type": "text",
  7. "analyzer": "bulgarian"
  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_bulgarian_analyzer
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "stem_exclusion_bulgarian_analyzer": {
  7. "type": "bulgarian",
  8. "stem_exclusion": ["авторитет", "одобрение"]
  9. }
  10. }
  11. }
  12. }
  13. }

copy

Bulgarian analyzer internals

The bulgarian analyzer is built using the following components:

  • Tokenizer: standard

  • Token filters:

    • lowercase
    • stop (Bulgarian)
    • keyword
    • stemmer (Bulgarian)

Custom Bulgarian analyzer

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

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

copy

Generated tokens

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

  1. POST /bulgarian-index/_analyze
  2. {
  3. "field": "content",
  4. "text": "Студентите учат в българските университети. Техните номера са 123456."
  5. }

copy

The response contains the generated tokens:

  1. {
  2. "tokens": [
  3. {"token": "студент","start_offset": 0,"end_offset": 10,"type": "<ALPHANUM>","position": 0},
  4. {"token": "учат","start_offset": 11,"end_offset": 15,"type": "<ALPHANUM>","position": 1},
  5. {"token": "българск","start_offset": 18,"end_offset": 29,"type": "<ALPHANUM>","position": 3},
  6. {"token": "университят","start_offset": 30,"end_offset": 42,"type": "<ALPHANUM>","position": 4},
  7. {"token": "техн","start_offset": 44,"end_offset": 51,"type": "<ALPHANUM>","position": 5},
  8. {"token": "номер","start_offset": 52,"end_offset": 58,"type": "<ALPHANUM>","position": 6},
  9. {"token": "123456","start_offset": 62,"end_offset": 68,"type": "<NUM>","position": 8}
  10. ]
  11. }