From d32dc38bed37eacc90de5a52d356832cccada0ee Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 13 Feb 2020 14:39:39 -0800 Subject: [PATCH] Move ClassifiedListing mappings to JSON file (#6061) [deploy] --- app/services/search/classified_listing.rb | 72 +------------------ .../mappings/classified_listings.json | 70 ++++++++++++++++++ 2 files changed, 72 insertions(+), 70 deletions(-) create mode 100644 config/elasticsearch/mappings/classified_listings.json diff --git a/app/services/search/classified_listing.rb b/app/services/search/classified_listing.rb index 9d4b3dd4c..30c93f915 100644 --- a/app/services/search/classified_listing.rb +++ b/app/services/search/classified_listing.rb @@ -2,6 +2,7 @@ module Search class ClassifiedListing INDEX_NAME = "classified_listings_#{Rails.env}".freeze INDEX_ALIAS = "classified_listings_#{Rails.env}_alias".freeze + MAPPINGS = JSON.parse(File.read("config/elasticsearch/mappings/classified_listings.json"), symbolize_names: true).freeze class << self def index(classified_listing_id, serialized_data) @@ -53,76 +54,7 @@ module Search end def mappings - { - dynamic: "strict", - properties: { - id: { - type: "keyword" - }, - author: { - dynamic: "strict", - properties: { - username: { - type: "keyword" - }, - name: { - type: "keyword" - }, - profile_image_90: { - type: "keyword" - } - } - }, - body_markdown: { - type: "text" - }, - bumped_at: { - type: "date" - }, - category: { - type: "keyword" - }, - contact_via_connect: { - type: "boolean" - }, - expires_at: { - type: "date" - }, - location: { - type: "text", - fields: { - raw: { - type: "keyword" - } - } - }, - processed_html: { - type: "keyword" - }, - slug: { - type: "text", - fields: { - raw: { - type: "keyword" - } - } - }, - tags: { - type: "keyword" - }, - title: { - type: "text", - fields: { - raw: { - type: "keyword" - } - } - }, - user_id: { - type: "keyword" - } - } - } + MAPPINGS end end end diff --git a/config/elasticsearch/mappings/classified_listings.json b/config/elasticsearch/mappings/classified_listings.json new file mode 100644 index 000000000..7dd7c1c11 --- /dev/null +++ b/config/elasticsearch/mappings/classified_listings.json @@ -0,0 +1,70 @@ +{ + "dynamic": "strict", + "properties": { + "id": { + "type": "keyword" + }, + "author": { + "dynamic": "strict", + "properties": { + "username": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "profile_image_90": { + "type": "keyword" + } + } + }, + "body_markdown": { + "type": "text" + }, + "bumped_at": { + "type": "date" + }, + "category": { + "type": "keyword" + }, + "contact_via_connect": { + "type": "boolean" + }, + "expires_at": { + "type": "date" + }, + "location": { + "type": "text", + "fields": { + "raw": { + "type": "keyword" + } + } + }, + "processed_html": { + "type": "keyword" + }, + "slug": { + "type": "text", + "fields": { + "raw": { + "type": "keyword" + } + } + }, + "tags": { + "type": "keyword" + }, + "title": { + "type": "text", + "fields": { + "raw": { + "type": "keyword" + } + } + }, + "user_id": { + "type": "keyword" + } + } +}