Skip to content

Commit

Permalink
Issue #20: add _field_caps support
Browse files Browse the repository at this point in the history
  • Loading branch information
idrissneumann committed Dec 27, 2023
1 parent 67f56ba commit 881e3e9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/quickwit/quickwit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 881e3e9

Please sign in to comment.