From 9f4dad77da97730baa85e304b9daf295ee889825 Mon Sep 17 00:00:00 2001 From: Molly Struve Date: Thu, 13 Feb 2020 11:33:47 -0500 Subject: [PATCH] Move Elasticsearch mappings to config folder as json file (#6051) [deploy] --- app/services/search/tag.rb | 30 ++----------------------- config/elasticsearch/mappings/tags.json | 28 +++++++++++++++++++++++ 2 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 config/elasticsearch/mappings/tags.json 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" + } + } +}