Skip to content

Conversation

@Seung-o
Copy link
Contributor

@Seung-o Seung-o commented Sep 28, 2025

Description

This PR adds missing TypeScript definitions for CombinedFieldsQuery in src/index.d.ts. The JavaScript implementation already exists and is exported properly, but TypeScript users were unable to use this query type due to missing type definitions.

Changes

  • ✨ Added CombinedFieldsQuery class definition with all methods and proper typing
  • ✨ Added combinedFieldsQuery factory function definition
  • ✨ Added comprehensive JSDoc comments with examples
  • ✅ Added TypeScript test cases in test/typedef.test.ts

Type Definitions Added

Class Definition

export class CombinedFieldsQuery extends FullTextQueryBase {
    constructor(fields?: string[] | string, queryString?: string);
    field(field: string): this;
    fields(fields: string[]): this;
    autoGenerateSynonymsPhraseQuery(enable: boolean): this;
    operator(operator: 'and' | 'or'): this;
    zeroTermsQuery(behavior: 'all' | 'none'): this;
}

Factory Function

export function combinedFieldsQuery(
    fields?: string[] | string,
    queryString?: string
): CombinedFieldsQuery;

Testing

  • ✅ All existing tests pass
  • ✅ TypeScript compilation succeeds without errors
  • ✅ New TypeScript test cases added and passing
  • ✅ 100% code coverage maintained

Usage Example

import * as esb from 'elastic-builder';

// Factory function
const query1 = esb.combinedFieldsQuery(['title', 'body'], 'Quick brown fox')
    .operator('and')
    .autoGenerateSynonymsPhraseQuery(true);

// Class constructor
const query2 = new esb.CombinedFieldsQuery(['title', 'content'], 'search terms')
    .zeroTermsQuery('all');

Fixes

Resolves TypeScript compilation errors when using CombinedFieldsQuery in TypeScript projects.


Note: This query was added in Elasticsearch 7.13+ and the JavaScript implementation has been available, but TypeScript definitions were missing.

@sudo-suhas sudo-suhas merged commit 5ce0325 into sudo-suhas:master Sep 28, 2025
8 checks passed
@github-actions
Copy link

🎉 This PR is included in version 3.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sudo-suhas
Copy link
Owner

Thanks for the PR @Seung-o 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants