From f3b7750282d4019536935087156fa5a15a68e843 Mon Sep 17 00:00:00 2001 From: Idriss Neumann Date: Wed, 27 Dec 2023 18:49:24 +0100 Subject: [PATCH] Issue #20: add _field_caps support --- pkg/quickwit/quickwit.go | 4 +++- src/datasource.ts | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/quickwit/quickwit.go b/pkg/quickwit/quickwit.go index 0aa9f1b..45047c4 100644 --- a/pkg/quickwit/quickwit.go +++ b/pkg/quickwit/quickwit.go @@ -143,7 +143,9 @@ func (ds *QuickwitDatasource) CallResource(ctx context.Context, req *backend.Cal // - empty string for fetching db version // - ?/_mapping for fetching index mapping // - _msearch for executing getTerms queries - if req.Path != "" && !strings.Contains(req.Path, "indexes/") && req.Path != "_elastic/_msearch" { + // - _field_caps for getting all the aggregeables fields + var isFieldCaps = req.Path != "" && strings.Contains(req.Path, "_elastic") && strings.Contains(req.Path, "/_field_caps") + if req.Path != "" && !strings.Contains(req.Path, "indexes/") && req.Path != "_elastic/_msearch" && !isFieldCaps { return fmt.Errorf("invalid resource URL: %s", req.Path) } diff --git a/src/datasource.ts b/src/datasource.ts index 3c309af..33ac5f1 100644 --- a/src/datasource.ts +++ b/src/datasource.ts @@ -348,7 +348,7 @@ export class QuickwitDataSource datetime: 'date', text: 'string', }; - return from(this.getResource('indexes/' + this.index)).pipe( + return from(this.getResource('_elastic/' + this.index + '/_field_caps')).pipe( map((index_metadata) => { const shouldAddField = (field: QuickwitField) => { const translated_type = typeMap[field.field_mapping.type];