Debian Codegraph @

search_queries_type.go

raw
1 // Copyright 2012-present Oliver Eilhard. All rights reserved.
2 // Use of this source code is governed by a MIT-license.
3 // See http://olivere.mit-license.org/license.txt for details.
4
5 package elastic
6
7 // TypeQuery filters documents matching the provided document / mapping type.
8 //
9 // For details, see:
10 // https://www.elastic.co/guide/en/elasticsearch/reference/5.2/query-dsl-type-query.html
11 type TypeQuery struct {
12 typ string
13 }
14
15 func NewTypeQuery(typ string) *TypeQuery {
16 return &TypeQuery{typ: typ}
17 }
18
19 // Source returns JSON for the query.
20 func (q *TypeQuery) Source() (interface{}, error) {
21 source := make(map[string]interface{})
22 params := make(map[string]interface{})
23 source["type"] = params
24 params["value"] = q.typ
25 return source, nil
26 }