on master help sign in
Update deprecated mapping specification

This was supposed to be deprecated in ES 5.x but I guess it got fully removed in 6 and is no harm in 5. ES split the "string" mapping type into unanalyzed "keyword" and analyzed "text". This updates the mapping for v5 to explicitly differentiate and is more deliberate about which fixed mapping fields are analyzed and which aren't.

commitf418eb32807b7066ed4d7968b0198cde49e17ede authorMichael Xavier <michael@michaelxavier.net> dateThu 8 Mar 2018, 16:14 (9 years ago) parente2ed228
2 files changed+28−15
.travis.yml+1−1 katip-elasticsearch/src/Katip/Scribes/ElasticSearch/Internal.hs+27−14
.travis.yml+1−1
@@ -20,8 +20,8 @@ matrix:
2020 - env: ARGS="--resolver=lts-8" ESVERSION=1.5.2 ESURL=https://download.elastic.co/elasticsearch/elasticsearch ESTESTARGS="--es-version 1"
2121 - env: ARGS="--resolver=lts-9" ESVERSION=1.5.2 ESURL=https://download.elastic.co/elasticsearch/elasticsearch ESTESTARGS="--es-version 1"
2222 - env: ARGS="--resolver=lts-10" ESVERSION=1.5.2 ESURL=https://download.elastic.co/elasticsearch/elasticsearch ESTESTARGS="--es-version 1"
23− - env: ARGS="--resolver=nightly" ESVERSION=1.5.2 ESURL=https://download.elastic.co/elasticsearch/elasticsearch ESTESTARGS="--es-version 1"
2423 - env: ARGS="--resolver=nightly" ESVERSION=5.5.0 ESURL=https://artifacts.elastic.co/downloads/elasticsearch ESTESTARGS="--es-version 5" ES_JAVA_OPTS="-Xms500m -Xmx750m" JAVA_HOME=/usr/lib/jvm/java-8-oracle
24+ - env: ARGS="--resolver=nightly" ESVERSION=6.2.2 ESURL=https://artifacts.elastic.co/downloads/elasticsearch ESTESTARGS="--es-version 5" ES_JAVA_OPTS="-Xms500m -Xmx750m" JAVA_HOME=/usr/lib/jvm/java-8-oracle
2525
2626before_install:
2727# Download and unpack the stack executable
katip-elasticsearch/src/Katip/Scribes/ElasticSearch/Internal.hs+27−14
@@ -320,24 +320,27 @@ mkEsScribe cfg@EsScribeCfg {..} env ix mapping sev verb = do
320320baseMapping :: ESVersion v => proxy v -> MappingName v -> Value
321321baseMapping prx mn =
322322 object [ fromMappingName prx mn .= object ["properties" .= object prs] ]
323− where prs = [ str "thread"
324− , str "sev"
325− , str "pid"
326− , str "ns"
327− , str "msg"
323+ where prs = [ unanalyzedString "thread"
324+ , unanalyzedString "sev"
325+ , unanalyzedString "pid"
326+ -- ns is frequently fulltext searched
327+ , analyzedString "ns"
328+ -- we want message to be fulltext searchable
329+ , analyzedString "msg"
328330 , "loc" .= locType
329− , str "host"
330− , str "env"
331+ , unanalyzedString "host"
332+ , unanalyzedString "env"
331333 , "at" .= dateType
332− , str "app"
334+ , unanalyzedString "app"
333335 ]
334− str k = k .= object ["type" .= String "string"]
336+ unanalyzedString k = k .= object ["type" .= String (unanalyzedStringType prx)]
337+ analyzedString k = k .= object ["type" .= String (analyzedStringType prx)]
335338 locType = object ["properties" .= object locPairs]
336− locPairs = [ str "loc_pkg"
337− , str "loc_mod"
338− , str "loc_ln"
339− , str "loc_fn"
340− , str "loc_col"
339+ locPairs = [ unanalyzedString "loc_pkg"
340+ , unanalyzedString "loc_mod"
341+ , unanalyzedString "loc_ln"
342+ , unanalyzedString "loc_fn"
343+ , unanalyzedString "loc_col"
341344 ]
342345 dateType = object [ "format" .= esDateFormat
343346 , "type" .= String "date"
@@ -459,6 +462,12 @@ class ESVersion v where
459462 putTemplate :: proxy v -> IndexTemplate v -> TemplateName v -> BH v IO (Response ByteString)
460463 putMapping :: (ToJSON a) => proxy v -> IndexName v -> MappingName v -> a -> BH v IO (Response ByteString)
461464
465+ -- In ES 5 and beyond, "string" was deprecated in favor of text for
466+ -- fulltext and keyword for unanalyzed tokens
467+ unanalyzedStringType :: proxy v -> Text
468+ analyzedStringType :: proxy v -> Text
469+
470+
462471
463472data ESV1 = ESV1
464473
@@ -488,6 +497,8 @@ instance ESVersion ESV1 where
488497 createIndex _ = V1.createIndex
489498 putTemplate _ = V1.putTemplate
490499 putMapping _ = V1.putMapping
500+ unanalyzedStringType _ = "string"
501+ analyzedStringType _ = "string"
491502
492503
493504data ESV5 = ESV5
@@ -518,3 +529,5 @@ instance ESVersion ESV5 where
518529 createIndex _ = V5.createIndex
519530 putTemplate _ = V5.putTemplate
520531 putMapping _ = V5.putMapping
532+ unanalyzedStringType _ = "keyword"
533+ analyzedStringType _ = "text"