- QueryAsAdmin - Search the index (admin)
- Autocomplete - Autocomplete
- RetrieveFeed - Feed of documents and events
- Recommendations - Recommend documents
- Query - Search
Retrieves results for search query without respect for permissions. This is available only to privileged users.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Search.QueryAsAdmin(ctx, components.SearchRequest{
TrackingToken: apiclientgo.Pointer("trackingToken"),
PageSize: apiclientgo.Pointer[int64](10),
Query: "vacation policy",
RequestOptions: &components.SearchRequestOptions{
FacetFilters: []components.FacetFilter{
components.FacetFilter{
FieldName: apiclientgo.Pointer("type"),
Values: []components.FacetFilterValue{
components.FacetFilterValue{
Value: apiclientgo.Pointer("article"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
components.FacetFilterValue{
Value: apiclientgo.Pointer("document"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
},
},
components.FacetFilter{
FieldName: apiclientgo.Pointer("department"),
Values: []components.FacetFilterValue{
components.FacetFilterValue{
Value: apiclientgo.Pointer("engineering"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
},
},
},
FacetBucketSize: 421489,
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.SearchResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
searchRequest |
components.SearchRequest | ✔️ | Admin search request | { "trackingToken": "trackingToken", "query": "vacation policy", "pageSize": 10, "requestOptions": { "facetFilters": [ { "fieldName": "type", "values": [ { "value": "article", "relationType": "EQUALS" }, { "value": "document", "relationType": "EQUALS" } ] }, { "fieldName": "department", "values": [ { "value": "engineering", "relationType": "EQUALS" } ] } ] } } |
locale |
*string |
➖ | The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
|
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AdminsearchResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.GleanDataError | 403, 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |
Retrieve query suggestions, operators and documents for the given partially typed query.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Search.Autocomplete(ctx, components.AutocompleteRequest{
TrackingToken: apiclientgo.Pointer("trackingToken"),
Query: apiclientgo.Pointer("what is a que"),
Datasource: apiclientgo.Pointer("GDRIVE"),
ResultSize: apiclientgo.Pointer[int64](10),
}, nil)
if err != nil {
log.Fatal(err)
}
if res.AutocompleteResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
autocompleteRequest |
components.AutocompleteRequest | ✔️ | Autocomplete request | { "trackingToken": "trackingToken", "query": "what is a que", "datasource": "GDRIVE", "resultSize": 10 } |
locale |
*string |
➖ | The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
|
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.AutocompleteResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.APIError | 4XX, 5XX | */* |
The personalized feed/home includes different types of contents including suggestions, recents, calendar events and many more.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Search.RetrieveFeed(ctx, components.FeedRequest{
TimeoutMillis: apiclientgo.Pointer[int64](5000),
}, nil)
if err != nil {
log.Fatal(err)
}
if res.FeedResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
feedRequest |
components.FeedRequest | ✔️ | Includes request params, client data and more for making user's feed. |
locale |
*string |
➖ | The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.FeedResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.APIError | 4XX, 5XX | */* |
Retrieve recommended documents for the given URL or Glean Document ID.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/types"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Search.Recommendations(ctx, components.RecommendationsRequest{
SourceDocument: &components.Document{
ContainerDocument: &components.Document{
Metadata: &components.DocumentMetadata{
Datasource: apiclientgo.Pointer("datasource"),
ObjectType: apiclientgo.Pointer("Feature Request"),
Container: apiclientgo.Pointer("container"),
ParentID: apiclientgo.Pointer("JIRA_EN-1337"),
MimeType: apiclientgo.Pointer("mimeType"),
DocumentID: apiclientgo.Pointer("documentId"),
CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
Author: &components.Person{
Name: "name",
ObfuscatedID: "<id>",
},
Components: []string{
"Backend",
"Networking",
},
Status: apiclientgo.Pointer("[\"Done\"]"),
CustomData: map[string]components.CustomDataValue{
"someCustomField": components.CustomDataValue{},
},
},
},
ParentDocument: &components.Document{
Metadata: &components.DocumentMetadata{
Datasource: apiclientgo.Pointer("datasource"),
ObjectType: apiclientgo.Pointer("Feature Request"),
Container: apiclientgo.Pointer("container"),
ParentID: apiclientgo.Pointer("JIRA_EN-1337"),
MimeType: apiclientgo.Pointer("mimeType"),
DocumentID: apiclientgo.Pointer("documentId"),
CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
Author: &components.Person{
Name: "name",
ObfuscatedID: "<id>",
},
Components: []string{
"Backend",
"Networking",
},
Status: apiclientgo.Pointer("[\"Done\"]"),
CustomData: map[string]components.CustomDataValue{
"someCustomField": components.CustomDataValue{},
},
},
},
Metadata: &components.DocumentMetadata{
Datasource: apiclientgo.Pointer("datasource"),
ObjectType: apiclientgo.Pointer("Feature Request"),
Container: apiclientgo.Pointer("container"),
ParentID: apiclientgo.Pointer("JIRA_EN-1337"),
MimeType: apiclientgo.Pointer("mimeType"),
DocumentID: apiclientgo.Pointer("documentId"),
CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
Author: &components.Person{
Name: "name",
ObfuscatedID: "abc123",
},
Components: []string{
"Backend",
"Networking",
},
Status: apiclientgo.Pointer("[\"Done\"]"),
CustomData: map[string]components.CustomDataValue{
"someCustomField": components.CustomDataValue{},
},
},
},
PageSize: apiclientgo.Pointer[int64](100),
MaxSnippetSize: apiclientgo.Pointer[int64](400),
RequestOptions: &components.RecommendationsRequestOptions{
FacetFilterSets: []components.FacetFilterSet{
components.FacetFilterSet{
Filters: []components.FacetFilter{
components.FacetFilter{
FieldName: apiclientgo.Pointer("type"),
Values: []components.FacetFilterValue{
components.FacetFilterValue{
Value: apiclientgo.Pointer("Spreadsheet"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
components.FacetFilterValue{
Value: apiclientgo.Pointer("Presentation"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
},
},
},
},
components.FacetFilterSet{
Filters: []components.FacetFilter{
components.FacetFilter{
FieldName: apiclientgo.Pointer("type"),
Values: []components.FacetFilterValue{
components.FacetFilterValue{
Value: apiclientgo.Pointer("Spreadsheet"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
components.FacetFilterValue{
Value: apiclientgo.Pointer("Presentation"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
},
},
},
},
components.FacetFilterSet{
Filters: []components.FacetFilter{
components.FacetFilter{
FieldName: apiclientgo.Pointer("type"),
Values: []components.FacetFilterValue{
components.FacetFilterValue{
Value: apiclientgo.Pointer("Spreadsheet"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
components.FacetFilterValue{
Value: apiclientgo.Pointer("Presentation"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
},
},
},
},
},
Context: &components.Document{
ContainerDocument: &components.Document{
Metadata: &components.DocumentMetadata{
Datasource: apiclientgo.Pointer("datasource"),
ObjectType: apiclientgo.Pointer("Feature Request"),
Container: apiclientgo.Pointer("container"),
ParentID: apiclientgo.Pointer("JIRA_EN-1337"),
MimeType: apiclientgo.Pointer("mimeType"),
DocumentID: apiclientgo.Pointer("documentId"),
CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
Author: &components.Person{
Name: "name",
ObfuscatedID: "<id>",
},
Components: []string{
"Backend",
"Networking",
},
Status: apiclientgo.Pointer("[\"Done\"]"),
CustomData: map[string]components.CustomDataValue{
"someCustomField": components.CustomDataValue{},
},
},
},
ParentDocument: &components.Document{
Metadata: &components.DocumentMetadata{
Datasource: apiclientgo.Pointer("datasource"),
ObjectType: apiclientgo.Pointer("Feature Request"),
Container: apiclientgo.Pointer("container"),
ParentID: apiclientgo.Pointer("JIRA_EN-1337"),
MimeType: apiclientgo.Pointer("mimeType"),
DocumentID: apiclientgo.Pointer("documentId"),
CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
Author: &components.Person{
Name: "name",
ObfuscatedID: "<id>",
},
Components: []string{
"Backend",
"Networking",
},
Status: apiclientgo.Pointer("[\"Done\"]"),
CustomData: map[string]components.CustomDataValue{
"someCustomField": components.CustomDataValue{},
},
},
},
Metadata: &components.DocumentMetadata{
Datasource: apiclientgo.Pointer("datasource"),
ObjectType: apiclientgo.Pointer("Feature Request"),
Container: apiclientgo.Pointer("container"),
ParentID: apiclientgo.Pointer("JIRA_EN-1337"),
MimeType: apiclientgo.Pointer("mimeType"),
DocumentID: apiclientgo.Pointer("documentId"),
CreateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
UpdateTime: types.MustNewTimeFromString("2000-01-23T04:56:07.000Z"),
Author: &components.Person{
Name: "name",
ObfuscatedID: "abc123",
},
Components: []string{
"Backend",
"Networking",
},
Status: apiclientgo.Pointer("[\"Done\"]"),
CustomData: map[string]components.CustomDataValue{
"someCustomField": components.CustomDataValue{},
},
},
},
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.ResultsResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description |
|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
recommendationsRequest |
components.RecommendationsRequest | ✔️ | Recommendations request |
locale |
*string |
➖ | The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.RecommendationsResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.APIError | 4XX, 5XX | */* |
Retrieve results from the index for the given query and filters.
package main
import(
"context"
"os"
apiclientgo "github.com/gleanwork/api-client-go"
"github.com/gleanwork/api-client-go/models/components"
"log"
)
func main() {
ctx := context.Background()
s := apiclientgo.New(
apiclientgo.WithSecurity(os.Getenv("GLEAN_API_TOKEN")),
)
res, err := s.Client.Search.Query(ctx, components.SearchRequest{
TrackingToken: apiclientgo.Pointer("trackingToken"),
PageSize: apiclientgo.Pointer[int64](10),
Query: "vacation policy",
RequestOptions: &components.SearchRequestOptions{
FacetFilters: []components.FacetFilter{
components.FacetFilter{
FieldName: apiclientgo.Pointer("type"),
Values: []components.FacetFilterValue{
components.FacetFilterValue{
Value: apiclientgo.Pointer("article"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
components.FacetFilterValue{
Value: apiclientgo.Pointer("document"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
},
},
components.FacetFilter{
FieldName: apiclientgo.Pointer("department"),
Values: []components.FacetFilterValue{
components.FacetFilterValue{
Value: apiclientgo.Pointer("engineering"),
RelationType: components.RelationTypeEquals.ToPointer(),
},
},
},
},
FacetBucketSize: 400611,
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.SearchResponse != nil {
// handle response
}
}| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. | |
searchRequest |
components.SearchRequest | ✔️ | Search request | { "trackingToken": "trackingToken", "query": "vacation policy", "pageSize": 10, "requestOptions": { "facetFilters": [ { "fieldName": "type", "values": [ { "value": "article", "relationType": "EQUALS" }, { "value": "document", "relationType": "EQUALS" } ] }, { "fieldName": "department", "values": [ { "value": "engineering", "relationType": "EQUALS" } ] } ] } } |
locale |
*string |
➖ | The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
|
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.SearchResponse, error
| Error Type | Status Code | Content Type |
|---|---|---|
| apierrors.GleanDataError | 403, 422 | application/json |
| apierrors.APIError | 4XX, 5XX | */* |