kgsearch

package
v0.196.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package kgsearch provides access to the Knowledge Graph Search API.

For product documentation, see: https://developers.google.com/knowledge-graph/

Library status

These client libraries are officially supported by Google. However, this library is considered complete and is in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.

When possible, we recommend using our newer [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) that are still actively being worked and iterated on.

Creating a client

Usage example:

import "google.golang.org/api/kgsearch/v1"
...
ctx := context.Background()
kgsearchService, err := kgsearch.NewService(ctx)

In this example, Google Application Default Credentials are used for authentication. For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.

Other authentication options

To use an API key for authentication (note: some APIs do not support API keys), use google.golang.org/api/option.WithAPIKey:

kgsearchService, err := kgsearch.NewService(ctx, option.WithAPIKey("AIza..."))

To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow, use google.golang.org/api/option.WithTokenSource:

config := &oauth2.Config{...}
// ...
token, err := config.Exchange(ctx, ...)
kgsearchService, err := kgsearch.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))

See google.golang.org/api/option.ClientOption for details on options.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntitiesSearchCall

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

func (*EntitiesSearchCall) Context

Context sets the context to be used in this call's Do method.

func (*EntitiesSearchCall) Do

Do executes the "kgsearch.entities.search" call. Any non-2xx status code is an error. Response headers are in either *SearchResponse.ServerResponse.Header or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.

func (*EntitiesSearchCall) Fields

Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more details.

func (*EntitiesSearchCall) Header

func (c *EntitiesSearchCall) Header() http.Header

Header returns a http.Header that can be modified by the caller to add headers to the request.

func (*EntitiesSearchCall) Ids

Ids sets the optional parameter "ids": The list of entity id to be used for search instead of query string. To specify multiple ids in the HTTP request, repeat the parameter in the URL as in ...?ids=A&ids=B

func (*EntitiesSearchCall) IfNoneMatch

func (c *EntitiesSearchCall) IfNoneMatch(entityTag string) *EntitiesSearchCall

IfNoneMatch sets an optional parameter which makes the operation fail if the object's ETag matches the given value. This is useful for getting updates only after the object has changed since the last request.

func (*EntitiesSearchCall) Indent

func (c *EntitiesSearchCall) Indent(indent bool) *EntitiesSearchCall

Indent sets the optional parameter "indent": Enables indenting of json results.

func (*EntitiesSearchCall) Languages

func (c *EntitiesSearchCall) Languages(languages ...string) *EntitiesSearchCall

Languages sets the optional parameter "languages": The list of language codes (defined in ISO 693) to run the query with, e.g. 'en'.

func (*EntitiesSearchCall) Limit

func (c *EntitiesSearchCall) Limit(limit int64) *EntitiesSearchCall

Limit sets the optional parameter "limit": Limits the number of entities to be returned.

func (*EntitiesSearchCall) Prefix

func (c *EntitiesSearchCall) Prefix(prefix bool) *EntitiesSearchCall

Prefix sets the optional parameter "prefix": Enables prefix match against names and aliases of entities

func (*EntitiesSearchCall) Query

func (c *EntitiesSearchCall) Query(query string) *EntitiesSearchCall

Query sets the optional parameter "query": The literal query string for search.

func (*EntitiesSearchCall) Types

func (c *EntitiesSearchCall) Types(types ...string) *EntitiesSearchCall

Types sets the optional parameter "types": Restricts returned entities with these types, e.g. Person (as defined in http://schema.org/Person). If multiple types are specified, returned entities will contain one or more of these types.

type EntitiesService

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

func NewEntitiesService

func NewEntitiesService(s *Service) *EntitiesService

func (*EntitiesService) Search

func (r *EntitiesService) Search() *EntitiesSearchCall

Search: Searches Knowledge Graph for entities that match the constraints. A list of matched entities will be returned in response, which will be in JSON-LD format and compatible with http://schema.org

type SearchResponse

type SearchResponse struct {
	// ItemListElement: The item list of search results.
	ItemListElement []interface{} `json:"itemListElement,omitempty"`

	// ServerResponse contains the HTTP response code and headers from the server.
	googleapi.ServerResponse `json:"-"`
	// ForceSendFields is a list of field names (e.g. "ItemListElement") to
	// unconditionally include in API requests. By default, fields with empty or
	// default values are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
	// details.
	ForceSendFields []string `json:"-"`
	// NullFields is a list of field names (e.g. "ItemListElement") to include in
	// API requests with the JSON null value. By default, fields with empty values
	// are omitted from API requests. See
	// https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
	NullFields []string `json:"-"`
}

SearchResponse: Response message includes the context and a list of matching results which contain the detail of associated entities.

func (SearchResponse) MarshalJSON

func (s SearchResponse) MarshalJSON() ([]byte, error)

type Service

type Service struct {
	BasePath  string // API endpoint base URL
	UserAgent string // optional additional User-Agent fragment

	Entities *EntitiesService
	// contains filtered or unexported fields
}

func New deprecated

func New(client *http.Client) (*Service, error)

New creates a new Service. It uses the provided http.Client for requests.

Deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.

func NewService

func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error)

NewService creates a new Service.

Jump to

Keyboard shortcuts

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