Greek analyzer

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

  1. PUT /greek-index
  2. {
  3. "mappings": {
  4. "properties": {
  5. "content": {
  6. "type": "text",
  7. "analyzer": "greek"
  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_greek_analyzer
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "stem_exclusion_greek_analyzer": {
  7. "type": "greek",
  8. "stem_exclusion": ["αρχή", "έγκριση"]
  9. }
  10. }
  11. }
  12. }
  13. }

copy

Greek analyzer internals

The greek analyzer is built using the following components:

  • Tokenizer: standard

  • Token filters:

    • lowercase
    • stop (Greek)
    • keyword
    • stemmer (Greek)

Custom Greek analyzer

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

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

copy

Generated tokens

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

  1. POST /greek-index/_analyze
  2. {
  3. "field": "content",
  4. "text": "Οι φοιτητές σπουδάζουν στα ελληνικά πανεπιστήμια. Οι αριθμοί τους είναι 123456."
  5. }

copy

The response contains the generated tokens:

  1. {
  2. "tokens": [
  3. {"token": "φοιτητές","start_offset": 3,"end_offset": 11,"type": "<ALPHANUM>","position": 1},
  4. {"token": "σπουδάζ","start_offset": 12,"end_offset": 22,"type": "<ALPHANUM>","position": 2},
  5. {"token": "στα","start_offset": 23,"end_offset": 26,"type": "<ALPHANUM>","position": 3},
  6. {"token": "ελληνικά","start_offset": 27,"end_offset": 35,"type": "<ALPHANUM>","position": 4},
  7. {"token": "πανεπιστήμ","start_offset": 36,"end_offset": 48,"type": "<ALPHANUM>","position": 5},
  8. {"token": "αριθμοί","start_offset": 53,"end_offset": 60,"type": "<ALPHANUM>","position": 7},
  9. {"token": "τους","start_offset": 61,"end_offset": 65,"type": "<ALPHANUM>","position": 8},
  10. {"token": "είνα","start_offset": 66,"end_offset": 71,"type": "<ALPHANUM>","position": 9},
  11. {"token": "123456","start_offset": 72,"end_offset": 78,"type": "<NUM>","position": 10}
  12. ]
  13. }