Sorani analyzer

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

  1. PUT /sorani-index
  2. {
  3. "mappings": {
  4. "properties": {
  5. "content": {
  6. "type": "text",
  7. "analyzer": "sorani"
  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_sorani_analyzer
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "stem_exclusion_sorani_analyzer": {
  7. "type": "sorani",
  8. "stem_exclusion": ["مؤسسه", "اجازه"]
  9. }
  10. }
  11. }
  12. }
  13. }

copy

Sorani analyzer internals

The sorani analyzer is built using the following components:

  • Tokenizer: standard

  • Token filters:

    • normalization (Sorani)
    • lowercase
    • decimal_digit
    • stop (Sorani)
    • keyword
    • stemmer (Sorani)

Custom Sorani analyzer

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

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

copy

Generated tokens

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

  1. POST /sorani-index/_analyze
  2. {
  3. "field": "content",
  4. "text": "خوێندنی فەرمی لە هەولێرەوە. ژمارەکان ١٢٣٤٥٦."
  5. }

copy

The response contains the generated tokens:

  1. {
  2. "tokens": [
  3. {
  4. "token": "خوێندن",
  5. "start_offset": 0,
  6. "end_offset": 7,
  7. "type": "<ALPHANUM>",
  8. "position": 0
  9. },
  10. {
  11. "token": "فەرم",
  12. "start_offset": 8,
  13. "end_offset": 13,
  14. "type": "<ALPHANUM>",
  15. "position": 1
  16. },
  17. {
  18. "token": "هەولێر",
  19. "start_offset": 17,
  20. "end_offset": 26,
  21. "type": "<ALPHANUM>",
  22. "position": 3
  23. },
  24. {
  25. "token": "ژمار",
  26. "start_offset": 28,
  27. "end_offset": 36,
  28. "type": "<ALPHANUM>",
  29. "position": 4
  30. },
  31. {
  32. "token": "123456",
  33. "start_offset": 37,
  34. "end_offset": 43,
  35. "type": "<NUM>",
  36. "position": 5
  37. }
  38. ]
  39. }