forked from aquasecurity/esquery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CBB-1170: add collapse support (#13)
* CBB-1170: add collapse support * CBB-1170: add constructor
- Loading branch information
1 parent
91b3efc
commit b248120
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package query | ||
|
||
// CollapseRequest represents the "collapse" param that can be applied to a request | ||
// see: https://www.elastic.co/guide/en/elasticsearch/reference/current/collapse-search-results.html | ||
type CollapseRequest struct { | ||
field string | ||
} | ||
|
||
// Collapse creates a new collapse request | ||
func Collapse(field string) *CollapseRequest { | ||
return &CollapseRequest{ | ||
field: field, | ||
} | ||
} | ||
|
||
// Map returns a map representation of the Source object. | ||
func (source CollapseRequest) Map() map[string]interface{} { | ||
return map[string]interface{}{ | ||
"field": source.field, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package query | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestCollapse_Map(t *testing.T) { | ||
runMapTests( | ||
t, | ||
[]mapTest{ | ||
{ | ||
name: "collapse", | ||
q: Collapse("collapse_field"), | ||
exp: map[string]interface{}{ | ||
"field": "collapse_field", | ||
}, | ||
}, | ||
}, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters