search

package
v1.43.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a dp-search-api client which can be used to make requests to the server

func NewClient

func NewClient(searchAPIURL string) *Client

NewClient creates a new instance of Client with a given search-api url

func NewWithHealthClient added in v1.33.5

func NewWithHealthClient(hcCli *healthcheck.Client) *Client

NewWithHealthClient creates a new instance of Client, reusing the URL and Clienter from the provided health check client.

func (*Client) Checker

func (c *Client) Checker(ctx context.Context, check *health.CheckState) error

Checker calls search api health endpoint and returns a check object to the caller.

func (*Client) GetDepartments added in v1.37.1

func (c *Client) GetDepartments(ctx context.Context, query url.Values) (d Department, err error)

GetDepartments returns the search results

func (*Client) GetSearch

func (c *Client) GetSearch(ctx context.Context, query url.Values) (r Response, err error)

GetSearch returns the search results

type Contact added in v1.34.1

type Contact struct {
	Name      string `json:"name"`
	Telephone string `json:"telephone,omitempty"`
	Email     string `json:"email"`
}

Contact represents each search result contact details

type ContentItem added in v1.34.1

type ContentItem struct {
	Description Description `json:"description"`
	Type        string      `json:"type"`
	URI         string      `json:"uri"`
	Matches     *Matches    `json:"matches,omitempty"`
}

ContentItem represents each search result

type ContentType added in v1.30.1

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

ContentType represents the specific content type for the search results with its respective count

type Department added in v1.37.1

type Department struct {
	Count int               `json:"count"`
	Took  int               `json:"took"`
	Items *[]DepartmentItem `json:"items"`
}

Department represents response from /departments/search end point

type DepartmentItem added in v1.37.1

type DepartmentItem struct {
	Code    string             `json:"code"`
	Name    string             `json:"name"`
	URL     string             `json:"url"`
	Matches *[]DepartmentMatch `json:"matches"`
}

DepartmentItem represents a department

type DepartmentMatch added in v1.37.1

type DepartmentMatch struct {
	Terms *[]MatchDetails `json:"terms"`
}

DepartmentMatch represents a department matches term

type Description added in v1.34.1

type Description struct {
	Contact           *Contact  `json:"contact,omitempty"`
	DatasetID         string    `json:"dataset_id,omitempty"`
	Edition           string    `json:"edition,omitempty"`
	Headline1         string    `json:"headline1,omitempty"`
	Headline2         string    `json:"headline2,omitempty"`
	Headline3         string    `json:"headline3,omitempty"`
	Keywords          *[]string `json:"keywords,omitempty"`
	LatestRelease     *bool     `json:"latest_release,omitempty"`
	Language          string    `json:"language,omitempty"`
	MetaDescription   string    `json:"meta_description,omitempty"`
	NationalStatistic *bool     `json:"national_statistic,omitempty"`
	NextRelease       string    `json:"next_release,omitempty"`
	PreUnit           string    `json:"pre_unit,omitempty"`
	ReleaseDate       string    `json:"release_date,omitempty"`
	Source            string    `json:"source,omitempty"`
	Summary           string    `json:"summary"`
	Title             string    `json:"title"`
	Unit              string    `json:"unit,omitempty"`
}

Description represents each search result description

type ErrInvalidSearchResponse

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

ErrInvalidSearchResponse is returned when the dp-search-api does not respond with a valid status

func NewSearchErrorResponse

func NewSearchErrorResponse(resp *http.Response, uri string) (e *ErrInvalidSearchResponse)

NewSearchErrorResponse creates an error response

func (ErrInvalidSearchResponse) Code

func (e ErrInvalidSearchResponse) Code() int

Code returns the status code received from dp-search-api if an error is returned

func (ErrInvalidSearchResponse) Error

func (e ErrInvalidSearchResponse) Error() string

Error should be called by the user to print out the stringified version of the error

type MatchDetails added in v1.34.1

type MatchDetails struct {
	Value string `json:"value,omitempty"`
	Start int    `json:"start"`
	End   int    `json:"end"`
}

MatchDetails represents each search result matches' details

type Matches added in v1.34.1

type Matches struct {
	Description struct {
		Summary         *[]MatchDetails `json:"summary"`
		Title           *[]MatchDetails `json:"title"`
		Edition         *[]MatchDetails `json:"edition,omitempty"`
		MetaDescription *[]MatchDetails `json:"meta_description,omitempty"`
		Keywords        *[]MatchDetails `json:"keywords,omitempty"`
		DatasetID       *[]MatchDetails `json:"dataset_id,omitempty"`
	} `json:"description"`
}

Matches represents each search result matches

type Response

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

Response represents the fields for the search results as returned by dp-search-api

Jump to

Keyboard shortcuts

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