transformer

package
v1.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContentItem added in v1.13.0

type ContentItem struct {
	Description description `json:"description"`
	Type        string      `json:"type"`
	URI         string      `json:"uri"`
}

type ContentType added in v1.13.0

type ContentType struct {
	Type  string `json:"type"`
	Count int    `json:"count"`
}

type ESBucket added in v1.13.0

type ESBucket struct {
	Key   string `json:"key"`
	Count int    `json:"doc_count"`
}

type ESHighlight added in v1.13.0

type ESHighlight struct {
	DescriptionTitle     *[]string `json:"description.title"`
	DescriptionEdition   *[]string `json:"description.edition"`
	DescriptionSummary   *[]string `json:"description.summary"`
	DescriptionMeta      *[]string `json:"description.metaDescription"`
	DescriptionKeywords  *[]string `json:"description.keywords"`
	DescriptionDatasetID *[]string `json:"description.datasetId"`
}

type ESResponse added in v1.13.0

type ESResponse struct {
	Responses []ESResponseItem `json:"responses"`
}

type ESResponseAggregations added in v1.13.0

type ESResponseAggregations struct {
	DocCounts struct {
		Buckets []ESBucket `json:"buckets"`
	} `json:"docCounts"`
}

type ESResponseHit added in v1.13.0

type ESResponseHit struct {
	Source    ESSourceDocument `json:"_source"`
	Highlight ESHighlight      `json:"highlight"`
}

type ESResponseHits added in v1.13.0

type ESResponseHits struct {
	Total int
	Hits  []ESResponseHit `json:"hits"`
}

type ESResponseItem added in v1.13.0

type ESResponseItem struct {
	Took         int                    `json:"took"`
	Hits         ESResponseHits         `json:"hits"`
	Aggregations ESResponseAggregations `json:"aggregations"`
	Suggest      ESSuggest              `json:"suggest"`
}

type ESSearchSuggest added in v1.13.0

type ESSearchSuggest struct {
	Options []ESSearchSuggestOptions `json:"options"`
}

type ESSearchSuggestOptions added in v1.13.0

type ESSearchSuggestOptions struct {
	Text string `json:"text"`
}

type ESSourceDocument added in v1.13.0

type ESSourceDocument struct {
	Description struct {
		Summary           string    `json:"summary"`
		NextRelease       string    `json:"nextRelease,omitempty"`
		Unit              string    `json:"unit,omitempty"`
		Keywords          *[]string `json:"keywords,omitempty"`
		ReleaseDate       string    `json:"releaseDate,omitempty"`
		Edition           string    `json:"edition,omitempty"`
		LatestRelease     *bool     `json:"latestRelease,omitempty"`
		Language          string    `json:"language,omitempty"`
		Contact           *contact  `json:"contact,omitempty"`
		DatasetID         string    `json:"datasetId,omitempty"`
		Source            string    `json:"source,omitempty"`
		Title             string    `json:"title"`
		MetaDescription   string    `json:"metaDescription,omitempty"`
		NationalStatistic *bool     `json:"nationalStatistic,omitempty"`
		PreUnit           string    `json:"preUnit,omitempty"`
		Headline1         string    `json:"headline1,omitempty"`
		Headline2         string    `json:"headline2,omitempty"`
		Headline3         string    `json:"headline3,omitempty"`
	} `json:"description"`
	Type string `json:"type"`
	URI  string `json:"uri"`
}

type ESSuggest added in v1.13.0

type ESSuggest struct {
	SearchSuggest []ESSearchSuggest `json:"search_suggest"`
}

type SearchResponse added in v1.13.0

type SearchResponse struct {
	Count               int           `json:"count"`
	Took                int           `json:"took"`
	ContentTypes        []ContentType `json:"content_types"`
	Items               []ContentItem `json:"items"`
	Suggestions         []string      `json:"suggestions,omitempty"`
	AdditionSuggestions []string      `json:"additional_suggestions,omitempty"`
}

Structs representing the transformed response

type Transformer

type Transformer struct {
	// contains filtered or unexported fields
}

Transformer represents an instance of the ResponseTransformer interface

func New

func New() *Transformer

New returns a new instance of Transformer

func (*Transformer) TransformSearchResponse

func (t *Transformer) TransformSearchResponse(ctx context.Context, responseData []byte, query string, highlight bool) ([]byte, error)

TransformSearchResponse transforms an elastic search response into a structure that matches the v1 api specification

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL