on master help sign in
Fix analyzed/unanalyzed bug in ESV1

When we started differentiating katip internal fields being analyzed or not, I did not go back and propagate this to ESV1. This is a typewise minor release but because it changes index semantics moving forward, I will probably release as a major version. In effect, if you use ESV1, this will update your mapping on setup and any new indices (e.g. if you use daily indexing, tomorrow's logs) will correctly stop analyzing various fields that are meant to be tokens. Without doing this, it is difficult to filter logs precisely on things like host if there's dashes or something in your hostnames.

commit68c4fd2d13bd00ae218d22ba0c2dd59b724a8ea9 authorMichael Xavier <michael@michaelxavier.net> dateFri 21 Sep 2018, 13:03 (8 years ago) parent6751eb3
1 file changed+18−8
katip-elasticsearch/src/Katip/Scribes/ElasticSearch/Internal.hs+18−8
katip-elasticsearch/src/Katip/Scribes/ElasticSearch/Internal.hs+18−8
@@ -345,8 +345,8 @@ baseMapping prx mn =
345345 , "at" .= dateType
346346 , unanalyzedString "app"
347347 ]
348− unanalyzedString k = k .= object ["type" .= String (unanalyzedStringType prx)]
349− analyzedString k = k .= object ["type" .= String (analyzedStringType prx)]
348+ unanalyzedString k = k .= unanalyzedStringSpec prx
349+ analyzedString k = k .= analyzedStringSpec prx
350350 locType = object ["properties" .= object locPairs]
351351 locPairs = [ unanalyzedString "loc_pkg"
352352 , unanalyzedString "loc_mod"
@@ -480,8 +480,8 @@ class ESVersion v where
480480
481481 -- In ES 5 and beyond, "string" was deprecated in favor of text for
482482 -- fulltext and keyword for unanalyzed tokens
483− unanalyzedStringType :: proxy v -> Text
484− analyzedStringType :: proxy v -> Text
483+ unanalyzedStringSpec :: proxy v -> Value
484+ analyzedStringSpec :: proxy v -> Value
485485
486486
487487
@@ -517,8 +517,14 @@ instance ESVersion ESV1 where
517517 updateIndexSettings _ = V1.updateIndexSettings
518518 putTemplate _ = V1.putTemplate
519519 putMapping _ = V1.putMapping
520− unanalyzedStringType _ = "string"
521− analyzedStringType _ = "string"
520+ unanalyzedStringSpec _ = object
521+ [ "type" .= String "string"
522+ , "index" .= String "not_analyzed"
523+ ]
524+ analyzedStringSpec _ = object
525+ [ "type" .= String "string"
526+ , "index" .= String "analyzed"
527+ ]
522528
523529
524530data ESV5 = ESV5
@@ -553,5 +559,9 @@ instance ESVersion ESV5 where
553559 updateIndexSettings _ = V5.updateIndexSettings
554560 putTemplate _ = V5.putTemplate
555561 putMapping _ = V5.putMapping
556− unanalyzedStringType _ = "keyword"
557− analyzedStringType _ = "text"
562+ unanalyzedStringSpec _ = object
563+ [ "type" .= String "keyword"
564+ ]
565+ analyzedStringSpec _ = object
566+ [ "type" .= String "text"
567+ ]