diff --git a/pkg/quickwit/quickwit.go b/pkg/quickwit/quickwit.go index 0aa9f1b..293c3bd 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) } @@ -153,6 +155,7 @@ func (ds *QuickwitDatasource) CallResource(ctx context.Context, req *backend.Cal } resourcePath, err := url.Parse(req.Path) + if err != nil { return err } 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];