transformer

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 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 Breakdown

type Breakdown struct {
	Total       int `json:"total"`
	Provisional int `json:"provisional,omitempty"`
	Confirmed   int `json:"confirmed,omitempty"`
	Postponed   int `json:"postponed,omitempty"`
	Published   int `json:"published,omitempty"`
	Cancelled   int `json:"cancelled,omitempty"`
	Census      int `json:"census,omitempty"`
}

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 ESReleaseHighlight

type ESReleaseHighlight 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 ESReleaseResponse

type ESReleaseResponse struct {
	Took     int                      `json:"took"`
	TimedOut bool                     `json:"timed_out"`
	Hits     ESReleaseResponseSummary `json:"hits"`
}

type ESReleaseResponseHit

type ESReleaseResponseHit struct {
	Source    ESReleaseSourceDocument `json:"_source"`
	Highlight ESReleaseHighlight      `json:"highlight"`
}

type ESReleaseResponseSummary

type ESReleaseResponseSummary struct {
	Total int                    `json:"total"`
	Hits  []ESReleaseResponseHit `json:"hits"`
}

type ESReleaseSourceDocument

type ESReleaseSourceDocument struct {
	URI         string       `json:"uri"`
	DateChanges []dateChange `json:"dateChanges,omitempty"`

	Description struct {
		Title              string          `json:"title"`
		Summary            string          `json:"summary"`
		ReleaseDate        string          `json:"releaseDate,omitempty"`
		Published          bool            `json:"published"`
		Cancelled          bool            `json:"cancelled"`
		Finalised          bool            `json:"finalised"`
		Topics             []string        `json:"topics"`
		NationalStatistic  bool            `json:"nationalStatistic,omitempty"`
		Keywords           []string        `json:"keywords,omitempty"`
		NextRelease        string          `json:"nextRelease,omitempty"`
		CancellationNotice []string        `json:"cancellationNotice"`
		ProvisionalDate    string          `json:"provisionalDate"`
		Edition            string          `json:"edition,omitempty"`
		DatasetID          string          `json:"datasetId,omitempty"`
		LatestRelease      bool            `json:"latestRelease"`
		MetaDescription    string          `json:"metaDescription,omitempty"`
		Language           string          `json:"language,omitempty"`
		Source             string          `json:"source,omitempty"`
		Contact            *releaseContact `json:"contact,omitempty"`
	} `json:"description"`
}

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 Release

type Release struct {
	URI         string             `json:"uri"`
	Description ReleaseDescription `json:"description"`
	Highlight   *highlight         `json:"highlight,omitempty"`
}

type ReleaseDescription

type ReleaseDescription struct {
	Title              string          `json:"title"`
	Summary            string          `json:"summary"`
	ReleaseDate        string          `json:"release_date"`
	Published          bool            `json:"published"`
	Cancelled          bool            `json:"cancelled"`
	Finalised          bool            `json:"finalised"`
	Postponed          bool            `json:"postponed"`
	Census             bool            `json:"census"`
	NationalStatistic  bool            `json:"national_statistic"`
	Keywords           []string        `json:"keywords,omitempty"`
	NextRelease        string          `json:"next_release,omitempty"`
	ProvisionalDate    string          `json:"provisional_date,omitempty"`
	CancellationNotice []string        `json:"cancellation_notice,omitempty"`
	Edition            string          `json:"edition,omitempty"`
	DatasetID          string          `json:"dataset_id,omitempty"`
	LatestRelease      *bool           `json:"latest_release,omitempty"`
	MetaDescription    string          `json:"meta_description,omitempty"`
	Language           string          `json:"language,omitempty"`
	Source             string          `json:"source,omitempty"`
	Contact            *releaseContact `json:"contact,omitempty"`
}

type ReleaseTransformer

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

func NewReleaseTransformer

func NewReleaseTransformer() *ReleaseTransformer

func (*ReleaseTransformer) TransformSearchResponse

func (t *ReleaseTransformer) TransformSearchResponse(_ context.Context, responseData []byte, _ string, highlight bool) ([]byte, error)

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

type SearchReleaseResponse

type SearchReleaseResponse struct {
	Took      int       `json:"took"`
	Limit     int       `json:"limit"`
	Offset    int       `json:"offset"`
	Breakdown Breakdown `json:"breakdown"`
	Releases  []Release `json:"releases"`
}

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