import { MutationState } from './mutationstate.js'; import { SearchFacet } from './searchfacet.js'; import { SearchQuery } from './searchquery.js'; import { SearchSort } from './searchsort.js'; import { VectorSearch } from './vectorsearch.js'; /** * SearchMetaData represents the meta-data available from a search query. * * @category Full Text Search */ export declare class SearchMetaData { facets: Record; client_context_id: string; metrics: { took: number; total_rows: number; max_score: number; success_partition_count: number; error_partition_count: number; }; errors: Record; constructor(meta: SearchMetaData); } /** * SearchRow represents the data available from a row of a search query. * * @category Full Text Search */ export declare class SearchRow { /** * The name of the index returning this hit. */ index: string; /** * The ID of the document. */ id: string; /** * A float representing the relevance of the hit. * * @example 2.47089 */ score: number; /** * Describe the different locations matching the search. * Requires the `includeLocations` option. */ locations: Array<{ field: string; term: string; position: number; start_offset: number; end_offset: number; array_positions?: number[]; }>; /** * An object whose key is the field that matched and the value is an array of the string that matched, surrounded by ``. * Used to highlight search results. * Requires the `highlight` option. * * @see fields */ fragments: { [field: string]: [string, ...string[]]; }; /** * An object whose key is the field that matched and the value the value of the document field. * Requires the `fields` option. * * @see fragments */ fields: { [field: string]: string; } | undefined; explanation: object | undefined; constructor(row: SearchRow); } /** * Contains the results of a search query. * * @category Full Text Search */ export declare class SearchResult { /** * The rows which have been returned by the query. */ rows: SearchRow[]; /** * The meta-data which has been returned by the query. */ meta: SearchMetaData; /** * @internal */ constructor(data: SearchResult); } /** * Specifies the highlight style that should be used for matches in the results. * * @category Full Text Search */ export declare enum HighlightStyle { /** * Indicates that matches should be highlighted using HTML tags in the result text. */ HTML = "html", /** * Indicates that matches should be highlighted using ASCII coding in the result test. */ ANSI = "ansi" } /** * Represents the various scan consistency options that are available when * querying against the query service. * * @category Full Text Search */ export declare enum SearchScanConsistency { /** * Indicates that no specific consistency is required, this is the fastest * options, but results may not include the most recent operations which have * been performed. */ NotBounded = "not_bounded" } /** * @category Full Text Search */ export type SearchQueryOptions = { /** * Specifies the number of results to skip from the index before returning * results. */ skip?: number; /** * Specifies the limit to the number of results that should be returned. */ limit?: number; /** * Configures whether the result should contain the execution plan for the query. */ explain?: boolean; /** * Specifies how the highlighting should behave. Specifically which mode should be * used for highlighting as well as which fields should be highlighted. */ highlight?: { style?: HighlightStyle; fields?: string[]; }; /** * Specifies the collections which should be searched as part of the query. */ collections?: string[]; /** * Specifies the list of fields which should be searched. */ fields?: string[]; /** * Specifies any facets that should be included in the query. */ facets?: { [name: string]: SearchFacet; }; /** * Specifies a list of fields or SearchSort's to use when sorting the result sets. */ sort?: string[] | SearchSort[]; /** * Specifies that scoring should be disabled. This improves performance but makes it * impossible to sort based on how well a particular result scored. */ disableScoring?: boolean; /** * If set to true, will include the locations in the search result. * * @experimental This API is subject to change without notice. */ includeLocations?: boolean; /** * Specifies the consistency requirements when executing the query. * * @see SearchScanConsistency */ consistency?: SearchScanConsistency; /** * Specifies a MutationState which the query should be consistent with. * * @see {@link MutationState} */ consistentWith?: MutationState; /** * Specifies any additional parameters which should be passed to the query engine * when executing the query. */ raw?: { [key: string]: any; }; /** * The timeout for this operation, represented in milliseconds. */ timeout?: number; /** * Specifies that the search response should include the request JSON. */ showRequest?: boolean; /** * Specifies that the search request should appear in the log. */ logRequest?: boolean; /** * Specifies that the search response should appear in the log. */ logResponse?: boolean; }; /** * Represents a search query and/or vector search to execute via the Couchbase Full Text Search (FTS) service. * * @category Full Text Search */ export declare class SearchRequest { private _searchQuery; private _vectorSearch; constructor(query: SearchQuery | VectorSearch); /** * @internal */ get searchQuery(): SearchQuery | undefined; /** * @internal */ get vectorSearch(): VectorSearch | undefined; /** * Adds a search query to the request if the request does not already have a search query. * * @param query A SearchQuery to add to the request. */ withSearchQuery(query: SearchQuery): SearchRequest; /** * Adds a vector search to the request if the request does not already have a vector search. * * @param search A VectorSearch to add to the request. */ withVectorSearch(search: VectorSearch): SearchRequest; /** * Creates a search request. * * @param query Either a SearchQuery or VectorSearch to add to the search request. */ static create(query: SearchQuery | VectorSearch): SearchRequest; }