Skip to content

Commit

Permalink
add support for _ttl mapping field when using MappingOptions struct t…
Browse files Browse the repository at this point in the history
…o define mappings
  • Loading branch information
Keene, Ramin authored and Keene, Ramin committed Jul 16, 2015
1 parent 449623d commit edd7855
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/indicesputmapping.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type MappingOptions struct {
Routing *RoutingOptions `json:"_routing,omitempty"`
Size *SizeOptions `json:"_size,omitempty"`
Source *SourceOptions `json:"_source,omitempty"`
TTL *TTLOptions `json:"_ttl,omitempty"`
Type *TypeOptions `json:"_type,omitempty"`
Properties map[string]interface{} `json:"properties"`
}
Expand Down Expand Up @@ -66,6 +67,11 @@ type TypeOptions struct {
Index string `json:"index,omitempty"`
}

type TTLOptions struct {
Enabled bool `json:"enabled"`
Default string `json:"default,omitempty"`
}

type IdOptions struct {
Index string `json:"index,omitempty"`
Path string `json:"path,omitempty"`
Expand Down
2 changes: 2 additions & 0 deletions lib/indicesputmapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ func TestPutMapping(t *testing.T) {
Timestamp: TimestampOptions{Enabled: true},
Id: IdOptions{Index: "analyzed", Path: "id"},
Parent: &ParentOptions{Type: "testParent"},
TTL: &TTLOptions{Enabled: true, Default: "1w"},
Properties: map[string]interface{}{
// special properties that can't be expressed as tags
"multi_analyze": map[string]interface{}{
Expand All @@ -114,6 +115,7 @@ func TestPutMapping(t *testing.T) {
Timestamp: TimestampOptions{Enabled: true},
Id: IdOptions{Index: "analyzed", Path: "id"},
Parent: &ParentOptions{Type: "testParent"},
TTL: &TTLOptions{Enabled: true, Default: "1w"},
Properties: map[string]interface{}{
"NoJson": map[string]string{"type": "string"},
"dontIndex": map[string]string{"index": "no"},
Expand Down

0 comments on commit edd7855

Please sign in to comment.