Movatterモバイル変換


[0]ホーム

URL:


kgsearch

package
v0.257.0Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License:BSD-3-ClauseImports:18Imported by:4

Details

Repository

github.com/googleapis/google-api-go-client

Links

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, thislibrary is considered complete and is in maintenance mode. This meansthat we will address critical bugs and security issues but will not addany 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 forauthentication. For information on how to create and obtain ApplicationDefault Credentials, seehttps://developers.google.com/identity/protocols/application-default-credentials.

Other authentication options

To use an API key for authentication (note: some APIs do not support APIkeys), usegoogle.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 OAuthflow, usegoogle.golang.org/api/option.WithTokenSource:

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

Seegoogle.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

typeEntitiesSearchCall

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 checkwhether the returned error was because http.StatusNotModified was returned.

func (*EntitiesSearchCall)Fields

Fields allows partial responses to be retrieved. Seehttps://developers.google.com/gdata/docs/2.0/basics#PartialResponse for moredetails.

func (*EntitiesSearchCall)Header

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

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

func (*EntitiesSearchCall)Ids

Ids sets the optional parameter "ids": The list of entity id to be used forsearch 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(entityTagstring) *EntitiesSearchCall

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

func (*EntitiesSearchCall)Indent

func (c *EntitiesSearchCall) Indent(indentbool) *EntitiesSearchCall

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

func (*EntitiesSearchCall)Languages

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

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

func (*EntitiesSearchCall)Limit

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

func (*EntitiesSearchCall)Prefix

func (c *EntitiesSearchCall) Prefix(prefixbool) *EntitiesSearchCall

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

func (*EntitiesSearchCall)Query

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

func (*EntitiesSearchCall)Types

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

Types sets the optional parameter "types": Restricts returned entities withthese types, e.g. Person (as defined inhttp://schema.org/Person). Ifmultiple types are specified, returned entities will contain one or more ofthese types.

typeEntitiesService

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

funcNewEntitiesService

func NewEntitiesService(s *Service) *EntitiesService

func (*EntitiesService)Search

Search: Searches Knowledge Graph for entities that match the constraints. Alist of matched entities will be returned in response, which will be inJSON-LD format and compatible withhttp://schema.org

typeSearchResponse

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 matchingresults which contain the detail of associated entities.

func (SearchResponse)MarshalJSON

func (sSearchResponse) MarshalJSON() ([]byte,error)

typeService

type Service struct {BasePathstring// API endpoint base URLUserAgentstring// optional additional User-Agent fragmentEntities *EntitiesService// contains filtered or unexported fields}

funcNewdeprecated

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.

funcNewServiceadded inv0.3.0

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

NewService creates a new Service.

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp