From fbd2243fbf82e6c40ff5ff35297b75a3fcfa3194 Mon Sep 17 00:00:00 2001 From: aalsabag <43807484+aalsabag@users.noreply.github.com> Date: Fri, 9 Apr 2021 16:16:51 -0500 Subject: [PATCH] Esutils additions (#70) * added multiget es types * added bulk query types --- go/v1beta1/storage/esutil/types.go | 43 +++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/go/v1beta1/storage/esutil/types.go b/go/v1beta1/storage/esutil/types.go index 9f457e1..fdca3e3 100644 --- a/go/v1beta1/storage/esutil/types.go +++ b/go/v1beta1/storage/esutil/types.go @@ -16,6 +16,7 @@ package esutil import ( "encoding/json" + "github.com/rode/grafeas-elasticsearch/go/v1beta1/storage/filtering" ) @@ -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 { @@ -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 @@ -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"` +}