@@ -332,65 +332,68 @@ export class BaseQuickwitDataSource
332332 }
333333
334334 getFields ( spec : FieldCapsSpec = { } ) : Observable < MetricFindValue [ ] > {
335- const range = spec . range || getDefaultTimeRange ( ) ;
336- return from (
337- this . getResource ( '_elastic/' + this . index + '/_field_caps' , {
338- start_timestamp : Math . floor ( range . from . valueOf ( ) / SECOND ) ,
339- end_timestamp : Math . ceil ( range . to . valueOf ( ) / SECOND ) ,
340- } )
341- ) . pipe (
342- map ( ( field_capabilities_response : FieldCapabilitiesResponse ) => {
343- // Cache field → type on the datasource for modifyQuery to consult.
344- // Quickwit routes phrase queries to the text variant first on multi-indexed
345- // fields (text+keyword), and text fields don't index positions by default.
346- // So prefer 'text' when present — it drives safer operator choices downstream.
347- for ( const [ name , caps ] of Object . entries ( field_capabilities_response . fields ) ) {
348- const typeKeys = Object . keys ( caps ) ;
349- const chosen = typeKeys . includes ( 'text' ) ? 'text' : typeKeys [ 0 ] ;
350- if ( chosen ) {
351- this . fieldTypes [ name ] = chosen ;
352- }
353- }
354-
355- const shouldAddField = ( field : any ) => {
356- if ( spec . aggregatable !== undefined && field . aggregatable !== spec . aggregatable ) {
357- return false ;
358- }
359- if ( spec . searchable !== undefined && field . searchable !== spec . searchable ) {
360- return false ;
361- }
362- if (
363- spec . type &&
364- spec . type . length !== 0 &&
365- ! ( spec . type . includes ( field . type ) || spec . type . includes ( fieldTypeMap [ field . type ] ) )
366- ) {
367- return false ;
368- }
369- return true ;
370- } ;
371- const fieldCapabilities = Object . entries ( field_capabilities_response . fields )
372- . flatMap ( ( [ field_name , field_capabilities ] ) => {
373- return Object . values ( field_capabilities ) . map ( ( field_capability ) => {
374- field_capability . field_name = field_name ;
375- return field_capability ;
376- } ) ;
377- } )
378- . filter ( shouldAddField )
379- . map ( ( field_capability ) => {
380- return {
381- text : field_capability . field_name ,
382- type : fieldTypeMap [ field_capability . type ] ,
383- } ;
384- } ) ;
385- const uniquefieldCapabilities = fieldCapabilities
386- . filter (
387- ( field_capability , index , self ) =>
388- index === self . findIndex ( ( t ) => t . text === field_capability . text && t . type === field_capability . type )
389- )
390- . sort ( ( a , b ) => a . text . localeCompare ( b . text ) ) ;
391- return uniquefieldCapabilities ;
392- } )
393- ) ;
335+ // PATCH: Disable field_caps to avoid large responses on indices with many dynamic fields
336+ return of ( [ ] ) ;
337+
338+ // DISABLED: const range = spec.range || getDefaultTimeRange();
339+ // DISABLED: return from(
340+ // DISABLED: this.getResource('_elastic/' + this.index + '/_field_caps', {
341+ // DISABLED: start_timestamp: Math.floor(range.from.valueOf() / SECOND),
342+ // DISABLED: end_timestamp: Math.ceil(range.to.valueOf() / SECOND),
343+ // DISABLED: })
344+ // DISABLED: ).pipe(
345+ // DISABLED: map((field_capabilities_response: FieldCapabilitiesResponse) => {
346+ // DISABLED: // Cache field → type on the datasource for modifyQuery to consult.
347+ // DISABLED: // Quickwit routes phrase queries to the text variant first on multi-indexed
348+ // DISABLED: // fields (text+keyword), and text fields don't index positions by default.
349+ // DISABLED: // So prefer 'text' when present — it drives safer operator choices downstream.
350+ // DISABLED: for (const [name, caps] of Object.entries(field_capabilities_response.fields)) {
351+ // DISABLED: const typeKeys = Object.keys(caps);
352+ // DISABLED: const chosen = typeKeys.includes('text') ? 'text' : typeKeys[0];
353+ // DISABLED: if (chosen) {
354+ // DISABLED: this.fieldTypes[name] = chosen;
355+ // DISABLED: }
356+ // DISABLED: }
357+ // DISABLED:
358+ // DISABLED: const shouldAddField = (field: any) => {
359+ // DISABLED: if (spec.aggregatable !== undefined && field.aggregatable !== spec.aggregatable) {
360+ // DISABLED: return false;
361+ // DISABLED: }
362+ // DISABLED: if (spec.searchable !== undefined && field.searchable !== spec.searchable) {
363+ // DISABLED: return false;
364+ // DISABLED: }
365+ // DISABLED: if (
366+ // DISABLED: spec.type &&
367+ // DISABLED: spec.type.length !== 0 &&
368+ // DISABLED: !(spec.type.includes(field.type) || spec.type.includes(fieldTypeMap[field.type]))
369+ // DISABLED: ) {
370+ // DISABLED: return false;
371+ // DISABLED: }
372+ // DISABLED: return true;
373+ // DISABLED: };
374+ // DISABLED: const fieldCapabilities = Object.entries(field_capabilities_response.fields)
375+ // DISABLED: .flatMap(([field_name, field_capabilities]) => {
376+ // DISABLED: return Object.values(field_capabilities).map((field_capability) => {
377+ // DISABLED: field_capability.field_name = field_name;
378+ // DISABLED: return field_capability;
379+ // DISABLED: });
380+ // DISABLED: })
381+ // DISABLED: .filter(shouldAddField)
382+ // DISABLED: .map((field_capability) => {
383+ // DISABLED: return {
384+ // DISABLED: text: field_capability.field_name,
385+ // DISABLED: type: fieldTypeMap[field_capability.type],
386+ // DISABLED: };
387+ // DISABLED: });
388+ // DISABLED: const uniquefieldCapabilities = fieldCapabilities
389+ // DISABLED: .filter(
390+ // DISABLED: (field_capability, index, self) =>
391+ // DISABLED: index === self.findIndex((t) => t.text === field_capability.text && t.type === field_capability.type)
392+ // DISABLED: )
393+ // DISABLED: .sort((a, b) => a.text.localeCompare(b.text));
394+ // DISABLED: return uniquefieldCapabilities;
395+ // DISABLED: })
396+ // DISABLED: );
394397 }
395398
396399 /**
0 commit comments