Bengali analyzer

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

  1. PUT /bengali-index
  2. {
  3. "mappings": {
  4. "properties": {
  5. "content": {
  6. "type": "text",
  7. "analyzer": "bengali"
  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_bengali_analyzer
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "stem_exclusion_bengali_analyzer": {
  7. "type": "bengali",
  8. "stem_exclusion": ["কর্তৃপক্ষ", "অনুমোদন"]
  9. }
  10. }
  11. }
  12. }
  13. }

copy

Bengali analyzer internals

The bengali analyzer is built using the following components:

  • Tokenizer: standard

  • Token filters:

    • lowercase
    • decimal_digit
    • indic_normalization
    • normalization (Bengali)
    • stop (Bengali)
    • keyword
    • stemmer (Bengali)

Custom Bengali analyzer

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

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

copy

Generated tokens

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

  1. POST /bengali-index/_analyze
  2. {
  3. "field": "content",
  4. "text": "ছাত্ররা বিশ্ববিদ্যালয়ে পড়াশোনা করে। তাদের নম্বরগুলি ১২৩৪৫৬।"
  5. }

copy

The response contains the generated tokens:

  1. {
  2. "tokens": [
  3. {"token": "ছাত্র","start_offset": 0,"end_offset": 7,"type": "<ALPHANUM>","position": 0},
  4. {"token": "বিসসবিদালয়","start_offset": 8,"end_offset": 23,"type": "<ALPHANUM>","position": 1},
  5. {"token": "পরাসোন","start_offset": 24,"end_offset": 32,"type": "<ALPHANUM>","position": 2},
  6. {"token": "তা","start_offset": 38,"end_offset": 43,"type": "<ALPHANUM>","position": 4},
  7. {"token": "নমমর","start_offset": 44,"end_offset": 53,"type": "<ALPHANUM>","position": 5},
  8. {"token": "123456","start_offset": 54,"end_offset": 60,"type": "<NUM>","position": 6}
  9. ]
  10. }