From 4b1a322d46ab0d01d8f1cfa24dcba53feddfcce9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?France=CC=81=20Wilke?= <francewilke@gmail.com>
Date: Mon, 13 Dec 2021 09:30:56 +0200
Subject: [PATCH] Fix mapping (opensearch)

---
 search/time_series.go | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/search/time_series.go b/search/time_series.go
index d17fcc7..c0eebc1 100644
--- a/search/time_series.go
+++ b/search/time_series.go
@@ -220,10 +220,11 @@ func structMappingProperties(structType reflect.Type) (map[string]MappingPropert
 			}
 		}
 
-		//allow user to change that with a search tag on the field
+		// allow user to change that with a search tag on the field
+		skip := false
 		switch structField.Tag.Get("search") {
 		case "":
-			//no change
+			// no change
 		case "keyword":
 			fieldMapping.Type = "keyword"
 		case "long":
@@ -235,12 +236,18 @@ func structMappingProperties(structType reflect.Type) (map[string]MappingPropert
 		case "object":
 			fieldMapping.Type = "object"
 			fieldMapping.Enabled = false
+		case "-":
+			// do not include in mapping
+			skip = true
 		default:
 			return nil, errors.Errorf("Unknown search:\"%s\" on field(%s)", structField.Tag.Get("search"), structField.Name)
 		}
 
-		//add to index spec
-		properties[fieldName] = fieldMapping
+		// add to index spec
+		if !skip {
+			properties[fieldName] = fieldMapping
+		}
+
 	}
 	return properties, nil
 }
-- 
GitLab