Italian analyzer

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

  1. PUT /italian-index
  2. {
  3. "mappings": {
  4. "properties": {
  5. "content": {
  6. "type": "text",
  7. "analyzer": "italian"
  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_italian_analyzer
  2. {
  3. "settings": {
  4. "analysis": {
  5. "analyzer": {
  6. "stem_exclusion_italian_analyzer": {
  7. "type": "italian",
  8. "stem_exclusion": ["autorità", "approvazione"]
  9. }
  10. }
  11. }
  12. }
  13. }

copy

Italian analyzer internals

The italian analyzer is built using the following components:

  • Tokenizer: standard

  • Token filters:

    • elision (Italian)
    • lowercase
    • stop (Italian)
    • keyword
    • stemmer (Italian)

Custom Italian analyzer

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

  1. PUT /italian-index
  2. {
  3. "settings": {
  4. "analysis": {
  5. "filter": {
  6. "italian_stop": {
  7. "type": "stop",
  8. "stopwords": "_italian_"
  9. },
  10. "italian_elision": {
  11. "type": "elision",
  12. "articles": [
  13. "c", "l", "all", "dall", "dell",
  14. "nell", "sull", "coll", "pell",
  15. "gl", "agl", "dagl", "degl", "negl",
  16. "sugl", "un", "m", "t", "s", "v", "d"
  17. ],
  18. "articles_case": true
  19. },
  20. "italian_stemmer": {
  21. "type": "stemmer",
  22. "language": "light_italian"
  23. },
  24. "italian_keywords": {
  25. "type": "keyword_marker",
  26. "keywords": []
  27. }
  28. },
  29. "analyzer": {
  30. "italian_analyzer": {
  31. "type": "custom",
  32. "tokenizer": "standard",
  33. "filter": [
  34. "italian_elision",
  35. "lowercase",
  36. "italian_stop",
  37. "italian_keywords",
  38. "italian_stemmer"
  39. ]
  40. }
  41. }
  42. }
  43. },
  44. "mappings": {
  45. "properties": {
  46. "content": {
  47. "type": "text",
  48. "analyzer": "italian_analyzer"
  49. }
  50. }
  51. }
  52. }

copy

Generated tokens

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

  1. POST /italian-index/_analyze
  2. {
  3. "field": "content",
  4. "text": "Gli studenti studiano nelle università italiane. I loro numeri sono 123456."
  5. }

copy

The response contains the generated tokens:

  1. {
  2. "tokens": [
  3. {"token": "student","start_offset": 4,"end_offset": 12,"type": "<ALPHANUM>","position": 1},
  4. {"token": "studian","start_offset": 13,"end_offset": 21,"type": "<ALPHANUM>","position": 2},
  5. {"token": "universit","start_offset": 28,"end_offset": 38,"type": "<ALPHANUM>","position": 4},
  6. {"token": "italian","start_offset": 39,"end_offset": 47,"type": "<ALPHANUM>","position": 5},
  7. {"token": "numer","start_offset": 56,"end_offset": 62,"type": "<ALPHANUM>","position": 8},
  8. {"token": "123456","start_offset": 68,"end_offset": 74,"type": "<NUM>","position": 10}
  9. ]
  10. }