diff --git a/app/services/search/tag.rb b/app/services/search/tag.rb index 64bd8757d..455c5a050 100644 --- a/app/services/search/tag.rb +++ b/app/services/search/tag.rb @@ -2,6 +2,7 @@ module Search class Tag INDEX_NAME = "tags_#{Rails.env}".freeze INDEX_ALIAS = "tags_#{Rails.env}_alias".freeze + MAPPING = JSON.parse(File.read("config/elasticsearch/mappings/tags.json"), symbolize_names: true).freeze class << self def index(tag_id, serialized_data) @@ -53,34 +54,7 @@ module Search end def mappings - { - dynamic: "strict", - properties: { - id: { - type: "keyword" - }, - name: { - type: "text", - fields: { - raw: { - type: "keyword" - } - } - }, - hotness_score: { - type: "integer" - }, - supported: { - type: "boolean" - }, - short_summary: { - type: "text" - }, - rules_html: { - type: "text" - } - } - } + MAPPING end end end diff --git a/config/elasticsearch/mappings/tags.json b/config/elasticsearch/mappings/tags.json new file mode 100644 index 000000000..33f1000fe --- /dev/null +++ b/config/elasticsearch/mappings/tags.json @@ -0,0 +1,28 @@ +{ + "dynamic": "strict", + "properties": { + "id": { + "type": "keyword" + }, + "name": { + "type": "text", + "fields": { + "raw": { + "type": "keyword" + } + } + }, + "hotness_score": { + "type": "integer" + }, + "supported": { + "type": "boolean" + }, + "short_summary": { + "type": "text" + }, + "rules_html": { + "type": "text" + } + } +}