mappings-es7.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // TODO: https://redmine.weseek.co.jp/issues/168446
  2. import type { estypes } from '@elastic/elasticsearch7';
  3. type Mappings = {
  4. settings: NonNullable<estypes.IndicesCreateRequest['body']>['settings'];
  5. mappings: NonNullable<estypes.IndicesCreateRequest['body']>['mappings'];
  6. }
  7. export const mappings: Mappings = {
  8. settings: {
  9. analysis: {
  10. filter: {
  11. english_stop: {
  12. type: 'stop',
  13. stopwords: '_english_',
  14. },
  15. },
  16. tokenizer: {
  17. edge_ngram_tokenizer: {
  18. type: 'edge_ngram',
  19. min_gram: 2,
  20. max_gram: 20,
  21. token_chars: ['letter', 'digit'],
  22. },
  23. },
  24. analyzer: {
  25. japanese: {
  26. type: 'custom',
  27. tokenizer: 'kuromoji_tokenizer',
  28. char_filter: ['icu_normalizer'],
  29. },
  30. english_edge_ngram: {
  31. type: 'custom',
  32. tokenizer: 'edge_ngram_tokenizer',
  33. filter: [
  34. 'lowercase',
  35. 'english_stop',
  36. ],
  37. },
  38. },
  39. },
  40. },
  41. mappings: {
  42. properties: {
  43. path: {
  44. type: 'text',
  45. fields: {
  46. raw: {
  47. type: 'text',
  48. analyzer: 'keyword',
  49. },
  50. ja: {
  51. type: 'text',
  52. analyzer: 'japanese',
  53. },
  54. en: {
  55. type: 'text',
  56. analyzer: 'english_edge_ngram',
  57. search_analyzer: 'standard',
  58. },
  59. },
  60. },
  61. body: {
  62. type: 'text',
  63. fields: {
  64. ja: {
  65. type: 'text',
  66. analyzer: 'japanese',
  67. },
  68. en: {
  69. type: 'text',
  70. analyzer: 'english_edge_ngram',
  71. search_analyzer: 'standard',
  72. },
  73. },
  74. },
  75. body_embedded: {
  76. type: 'dense_vector',
  77. dims: 768,
  78. },
  79. comments: {
  80. type: 'text',
  81. fields: {
  82. ja: {
  83. type: 'text',
  84. analyzer: 'japanese',
  85. },
  86. en: {
  87. type: 'text',
  88. analyzer: 'english_edge_ngram',
  89. search_analyzer: 'standard',
  90. },
  91. },
  92. },
  93. username: {
  94. type: 'keyword',
  95. },
  96. comment_count: {
  97. type: 'integer',
  98. },
  99. bookmark_count: {
  100. type: 'integer',
  101. },
  102. like_count: {
  103. type: 'integer',
  104. },
  105. grant: {
  106. type: 'integer',
  107. },
  108. granted_users: {
  109. type: 'keyword',
  110. },
  111. granted_groups: {
  112. type: 'keyword',
  113. },
  114. created_at: {
  115. type: 'date',
  116. format: 'dateOptionalTime',
  117. },
  118. updated_at: {
  119. type: 'date',
  120. format: 'dateOptionalTime',
  121. },
  122. tag_names: {
  123. type: 'keyword',
  124. },
  125. },
  126. },
  127. };