search

package
v2.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: MIT Imports: 11 Imported by: 8

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

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

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

GetDepartments returns the search results

func (*Client) GetSearch

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

GetSearch returns the search results

type Contact

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

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

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

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

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

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

DepartmentMatch represents a department matches term

type Description

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

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

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