From 0f334c0939f87f28b399e08387c6bcfbc37aff2c Mon Sep 17 00:00:00 2001
From: higs4281 <higs4281@gmail.com>
Date: Tue, 6 Sep 2022 16:51:55 -0400
Subject: [PATCH] Adjust mappings settings to ignore periods in company names

The suggester for the 'Company name' filter gets led astray when
company names have periods in them, such as 'U.S. Bancorp'
If a user types in 'US Banc', nothing is suggested.

This change adds a filter and analyzer for Company name suggestions
that ignores periods, so that either 'US Banc' or 'U.S. Banc' will suggest
U.S. BANCORP.

This satisfies internal issue 2209.
---
 complaints/ccdb/ccdb_mapping.json |  4 ++--
 complaints/settings.json          | 12 ++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/complaints/ccdb/ccdb_mapping.json b/complaints/ccdb/ccdb_mapping.json
index fb52443..0f9905a 100644
--- a/complaints/ccdb/ccdb_mapping.json
+++ b/complaints/ccdb/ccdb_mapping.json
@@ -11,8 +11,8 @@
           "type": "keyword"
         },
         "suggest": {
-          "analyzer": "uppercase_analyzer",
-          "type": "text"
+          "type": "completion",
+          "analyzer": "entity"
         }
       },
       "analyzer": "cr_analyzer",
diff --git a/complaints/settings.json b/complaints/settings.json
index 01f2180..b827368 100644
--- a/complaints/settings.json
+++ b/complaints/settings.json
@@ -28,7 +28,19 @@
         "token_separator": " "
       }
     },
+    "char_filter": {
+      "entity": {
+        "type": "pattern_replace",
+        "pattern": "\\.",
+        "replacement": ""
+      }
+    },
     "analyzer": {
+      "entity": {
+        "type": "custom",
+        "tokenizer": "keyword",
+        "char_filter": ["entity"]
+      },
       "cr_analyzer": {
         "type": "custom",
         "tokenizer": "whitespace",