Skip to content

Commit

Permalink
Esutils additions (#70)
Browse files Browse the repository at this point in the history
* added multiget es types

* added bulk query types
  • Loading branch information
aalsabag committed Apr 9, 2021
1 parent 4a0e69e commit fbd2243
Showing 1 changed file with 40 additions and 3 deletions.
43 changes: 40 additions & 3 deletions go/v1beta1/storage/esutil/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package esutil

import (
"encoding/json"

"github.com/rode/grafeas-elasticsearch/go/v1beta1/storage/filtering"
)

Expand Down Expand Up @@ -86,19 +87,34 @@ type EsIndexDocError struct {
// Elasticsearch /_delete_by_query response

type EsDeleteResponse struct {
Deleted int `json:"deleted"`
Took int `json:"took"`
TimedOut bool `json:"timed_out"`
Total int `json:"total"`
Deleted int `json:"deleted"`
Batches int `json:"batches"`
VersionConflicts int `json:"version_conflicts"`
Noops int `json:"noops"`
ThrottledMillis int `json:"throttled_millis"`
RequestsPerSecond float64 `json:"requests_per_second"`
ThrottledUntilMillis int `json:"throttled_until_millis"`
Failures []interface{} `json:"failures"`
}

// Elasticsearch /_bulk query fragments

type EsBulkQueryFragment struct {
Index *EsBulkQueryIndexFragment `json:"index"`
Index *EsBulkQueryIndexFragment `json:"index"`
Create *EsBulkQueryCreateFragment `json:"create"`
}

type EsBulkQueryIndexFragment struct {
Index string `json:"_index"`
}

type EsBulkQueryCreateFragment struct {
Id string `json:"_id"`
}

// Elasticsearch /_bulk response

type EsBulkResponse struct {
Expand All @@ -107,7 +123,8 @@ type EsBulkResponse struct {
}

type EsBulkResponseItem struct {
Index *EsIndexDocResponse `json:"index,omitempty"`
Index *EsIndexDocResponse `json:"index,omitempty"`
Create *EsIndexDocResponse `json:"create,omitempty"`
}

// Elasticsearch /_msearch query fragments
Expand Down Expand Up @@ -231,3 +248,23 @@ type ESMappings struct {
type ESMeta struct {
Type string `json:"type,omitempty"`
}

type EsMultiGetRequest struct {
IDs []string `json:"ids"`
}

type EsMultiGetDocument struct {
ID string `json:"_id"`
Found bool `json:"found"`
}

type EsMultiGetResponse struct {
Docs []*EsMultiGetDocument `json:"docs"`
}

// response for index creation
type EsIndexResponse struct {
Acknowledged bool `json:"acknowledged"`
ShardsAcknowledged bool `json:"shards_acknowledged"`
Index string `json:"index"`
}

0 comments on commit fbd2243

Please sign in to comment.