mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 01:24:26 +00:00
30ce3731a1
* denisenkom/go-mssqldb untagged -> v0.9.0 * github.com/editorconfig/editorconfig-core-go v2.3.7 -> v2.3.8 * github.com/go-testfixtures/testfixtures v3.4.0 -> v3.4.1 * github.com/mholt/archiver v3.3.2 -> v3.5.0 * github.com/olivere/elastic v7.0.20 -> v7.0.21 * github.com/urfave/cli v1.22.4 -> v1.22.5 * github.com/xanzy/go-gitlab v0.38.1 -> v0.39.0 * github.com/yuin/goldmark-meta untagged -> v1.0.0 * github.com/ethantkoenig/rupture 0a76f03a811a -> c3b3b810dc77 * github.com/jaytaylor/html2text 8fb95d837f7d -> 3577fbdbcff7 * github.com/kballard/go-shellquote cd60e84ee657 -> 95032a82bc51 * github.com/msteinert/pam 02ccfbfaf0cc -> 913b8f8cdf8b * github.com/unknwon/paginater 7748a72e0141 -> 042474bd0eae * CI.restart() Co-authored-by: techknowlogick <techknowlogick@gitea.io>
176 lines
4.1 KiB
Go
Vendored
176 lines
4.1 KiB
Go
Vendored
// Copyright 2012-present Oliver Eilhard. All rights reserved.
|
|
// Use of this source code is governed by a MIT-license.
|
|
// See http://olivere.mit-license.org/license.txt for details.
|
|
|
|
package elastic
|
|
|
|
// InnerHit implements a simple join for parent/child, nested, and even
|
|
// top-level documents in Elasticsearch.
|
|
// It is an experimental feature for Elasticsearch versions 1.5 (or greater).
|
|
// See http://www.elastic.co/guide/en/elasticsearch/reference/7.0/search-request-inner-hits.html
|
|
// for documentation.
|
|
//
|
|
// See the tests for SearchSource, HasChildFilter, HasChildQuery,
|
|
// HasParentFilter, HasParentQuery, NestedFilter, and NestedQuery
|
|
// for usage examples.
|
|
type InnerHit struct {
|
|
source *SearchSource
|
|
path string
|
|
typ string
|
|
|
|
name string
|
|
}
|
|
|
|
// NewInnerHit creates a new InnerHit.
|
|
func NewInnerHit() *InnerHit {
|
|
return &InnerHit{source: NewSearchSource()}
|
|
}
|
|
|
|
func (hit *InnerHit) Path(path string) *InnerHit {
|
|
hit.path = path
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Type(typ string) *InnerHit {
|
|
hit.typ = typ
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Query(query Query) *InnerHit {
|
|
hit.source.Query(query)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Collapse(collapse *CollapseBuilder) *InnerHit {
|
|
hit.source.Collapse(collapse)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) From(from int) *InnerHit {
|
|
hit.source.From(from)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Size(size int) *InnerHit {
|
|
hit.source.Size(size)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) TrackScores(trackScores bool) *InnerHit {
|
|
hit.source.TrackScores(trackScores)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Explain(explain bool) *InnerHit {
|
|
hit.source.Explain(explain)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Version(version bool) *InnerHit {
|
|
hit.source.Version(version)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) StoredField(storedFieldName string) *InnerHit {
|
|
hit.source.StoredField(storedFieldName)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) StoredFields(storedFieldNames ...string) *InnerHit {
|
|
hit.source.StoredFields(storedFieldNames...)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) NoStoredFields() *InnerHit {
|
|
hit.source.NoStoredFields()
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) FetchSource(fetchSource bool) *InnerHit {
|
|
hit.source.FetchSource(fetchSource)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) FetchSourceContext(fetchSourceContext *FetchSourceContext) *InnerHit {
|
|
hit.source.FetchSourceContext(fetchSourceContext)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) DocvalueFields(docvalueFields ...string) *InnerHit {
|
|
hit.source.DocvalueFields(docvalueFields...)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) DocvalueFieldsWithFormat(docvalueFields ...DocvalueField) *InnerHit {
|
|
hit.source.DocvalueFieldsWithFormat(docvalueFields...)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) DocvalueField(docvalueField string) *InnerHit {
|
|
hit.source.DocvalueField(docvalueField)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) DocvalueFieldWithFormat(docvalueField DocvalueField) *InnerHit {
|
|
hit.source.DocvalueFieldWithFormat(docvalueField)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) ScriptFields(scriptFields ...*ScriptField) *InnerHit {
|
|
hit.source.ScriptFields(scriptFields...)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) ScriptField(scriptField *ScriptField) *InnerHit {
|
|
hit.source.ScriptField(scriptField)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Sort(field string, ascending bool) *InnerHit {
|
|
hit.source.Sort(field, ascending)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) SortWithInfo(info SortInfo) *InnerHit {
|
|
hit.source.SortWithInfo(info)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) SortBy(sorter ...Sorter) *InnerHit {
|
|
hit.source.SortBy(sorter...)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Highlight(highlight *Highlight) *InnerHit {
|
|
hit.source.Highlight(highlight)
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Highlighter() *Highlight {
|
|
return hit.source.Highlighter()
|
|
}
|
|
|
|
func (hit *InnerHit) Name(name string) *InnerHit {
|
|
hit.name = name
|
|
return hit
|
|
}
|
|
|
|
func (hit *InnerHit) Source() (interface{}, error) {
|
|
src, err := hit.source.Source()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
source, ok := src.(map[string]interface{})
|
|
if !ok {
|
|
return nil, nil
|
|
}
|
|
|
|
// Notice that hit.typ and hit.path are not exported here.
|
|
// They are only used with SearchSource and serialized there.
|
|
|
|
if hit.name != "" {
|
|
source["name"] = hit.name
|
|
}
|
|
return source, nil
|
|
}
|