Skip to content

Commit

Permalink
Rename VectorQueryOptions to FindNearestOptions for cross-SDK consist…
Browse files Browse the repository at this point in the history
…ency
  • Loading branch information
MarkDuckworth committed Aug 21, 2024
1 parent 873dd12 commit 33b1cf8
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
58 changes: 29 additions & 29 deletions api-report/firestore.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,16 @@ export abstract class Filter {
static where(fieldPath: string | firestore.FieldPath, opStr: firestore.WhereFilterOp, value: unknown): Filter;
}

// @public
export interface FindNearestOptions {
distanceMeasure: 'EUCLIDEAN' | 'COSINE' | 'DOT_PRODUCT';
distanceResultField?: string | firestore.FieldPath;
distanceThreshold?: number;
limit: number;
queryVector: firestore.VectorValue | Array<number>;
vectorField: string | firestore.FieldPath;
}

// Warning: (tsdoc-undefined-tag) The TSDoc tag "@class" is not defined in this configuration
//
// @public
Expand Down Expand Up @@ -1048,9 +1058,9 @@ export class Query<AppModelType = firestore.DocumentData, DbModelType extends fi
limit: number;
distanceMeasure: 'EUCLIDEAN' | 'COSINE' | 'DOT_PRODUCT';
}): VectorQuery<AppModelType, DbModelType>;
findNearest(options: VectorQueryOptions): VectorQuery<AppModelType, DbModelType>;
findNearest(options: FindNearestOptions): VectorQuery<AppModelType, DbModelType>;
// (undocumented)
_findNearest(options: VectorQueryOptions): VectorQuery<AppModelType, DbModelType>;
_findNearest(options: FindNearestOptions): VectorQuery<AppModelType, DbModelType>;
// Warning: (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
// Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@type" is not defined in this configuration
Expand Down Expand Up @@ -1459,7 +1469,7 @@ export class VectorQuery<AppModelType = firestore.DocumentData, DbModelType exte
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
//
// @internal
constructor(_query: Query<AppModelType, DbModelType>, _options: VectorQueryOptions);
constructor(_query: Query<AppModelType, DbModelType>, _options: FindNearestOptions);
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
//
// @internal
Expand Down Expand Up @@ -1489,16 +1499,6 @@ export class VectorQuery<AppModelType = firestore.DocumentData, DbModelType exte
toProto(transactionOrReadTime?: Uint8Array | Timestamp | api.ITransactionOptions, explainOptions?: firestore.ExplainOptions): api.IRunQueryRequest;
}

// @public
export interface VectorQueryOptions {
distanceMeasure: 'EUCLIDEAN' | 'COSINE' | 'DOT_PRODUCT';
distanceResultField?: string | firestore.FieldPath;
distanceThreshold?: number;
limit: number;
queryVector: firestore.VectorValue | Array<number>;
vectorField: string | firestore.FieldPath;
}

// @public
export class VectorQuerySnapshot<AppModelType = firestore.DocumentData, DbModelType extends firestore.DocumentData = firestore.DocumentData> implements firestore.VectorQuerySnapshot<AppModelType, DbModelType> {
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
Expand Down Expand Up @@ -1685,22 +1685,22 @@ export class WriteResult implements firestore.WriteResult {
// build/src/reference/field-order.d.ts:22:4 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/field-order.d.ts:24:4 - (tsdoc-undefined-tag) The TSDoc tag "@class" is not defined in this configuration
// build/src/reference/query-options.d.ts:27:4 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:418:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration
// build/src/reference/query.d.ts:424:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:426:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:434:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:436:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:436:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// build/src/reference/query.d.ts:438:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:438:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// build/src/reference/query.d.ts:440:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:442:24 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
// build/src/reference/query.d.ts:442:17 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
// build/src/reference/query.d.ts:451:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:453:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration
// build/src/reference/query.d.ts:455:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:641:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:642:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:425:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration
// build/src/reference/query.d.ts:431:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:433:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:441:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:443:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:443:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// build/src/reference/query.d.ts:445:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:445:15 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
// build/src/reference/query.d.ts:447:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:449:24 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
// build/src/reference/query.d.ts:449:17 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
// build/src/reference/query.d.ts:458:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:460:8 - (tsdoc-undefined-tag) The TSDoc tag "@return" is not defined in this configuration
// build/src/reference/query.d.ts:462:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/query.d.ts:648:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
// build/src/reference/query.d.ts:649:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/vector-query.d.ts:50:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/vector-query.d.ts:55:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
// build/src/reference/vector-query.d.ts:60:8 - (tsdoc-undefined-tag) The TSDoc tag "@private" is not defined in this configuration
Expand Down
2 changes: 1 addition & 1 deletion dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export type {AggregateQuery} from './reference/aggregate-query';
export type {AggregateQuerySnapshot} from './reference/aggregate-query-snapshot';
export type {VectorQuery} from './reference/vector-query';
export type {VectorQuerySnapshot} from './reference/vector-query-snapshot';
export type {VectorQueryOptions} from './reference/vector-query-options';
export type {FindNearestOptions} from './reference/find-nearest-options';
export {BulkWriter} from './bulk-writer';
export type {BulkWriterError} from './bulk-writer';
export type {BundleBuilder} from './bundle';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import * as firestore from '@google-cloud/firestore';
/**
* Specifies the behavior of the {@link VectorQuery} generated by a call to {@link Query.findNearest}.
*/
export interface VectorQueryOptions {
export interface FindNearestOptions {
/**
* A string or {@link FieldPath} specifying the vector field to search on.
*/
Expand Down
14 changes: 7 additions & 7 deletions dev/src/reference/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {FilterInternal} from './filter-internal';
import {FieldFilterInternal} from './field-filter-internal';
import {CompositeFilterInternal} from './composite-filter-internal';
import {comparisonOperators, directionOperators} from './constants';
import {VectorQueryOptions} from './vector-query-options';
import {FindNearestOptions} from './find-nearest-options';
import {DocumentReference} from './document-reference';
import {QuerySnapshot} from './query-snapshot';
import {Serializer} from '../serializer';
Expand Down Expand Up @@ -668,14 +668,14 @@ export class Query<
* querySnapshot.forEach(...);
* ```
* @param options - An argument specifying the behavior of the {@link VectorQuery} returned by this function.
* See {@link VectorQueryOptions}.
* See {@link FindNearestOptions}.
*/
findNearest(
options: VectorQueryOptions
options: FindNearestOptions
): VectorQuery<AppModelType, DbModelType>;

findNearest(
vectorFieldOrOptions: string | firestore.FieldPath | VectorQueryOptions,
vectorFieldOrOptions: string | firestore.FieldPath | FindNearestOptions,
queryVector?: firestore.VectorValue | Array<number>,
options?: {
limit?: number;
Expand All @@ -686,20 +686,20 @@ export class Query<
typeof vectorFieldOrOptions === 'string' ||
vectorFieldOrOptions instanceof FieldPath
) {
const fnOptions: VectorQueryOptions = {
const fnOptions: FindNearestOptions = {
distanceMeasure: options!.distanceMeasure!,
limit: options!.limit!,
queryVector: queryVector!,
vectorField: vectorFieldOrOptions,
};
return this._findNearest(fnOptions);
} else {
return this._findNearest(vectorFieldOrOptions as VectorQueryOptions);
return this._findNearest(vectorFieldOrOptions as FindNearestOptions);
}
}

_findNearest(
options: VectorQueryOptions
options: FindNearestOptions
): VectorQuery<AppModelType, DbModelType> {
validateFieldPath('vectorField', options.vectorField);

Expand Down
4 changes: 2 additions & 2 deletions dev/src/reference/vector-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {DocumentChange} from '../document-change';
import {isPrimitiveArrayEqual} from '../util';
import {QueryUtil} from './query-util';
import {Query} from './query';
import {VectorQueryOptions} from './vector-query-options';
import {FindNearestOptions} from './find-nearest-options';
import {VectorQuerySnapshot} from './vector-query-snapshot';
import {ExplainResults} from '../query-profile';
import {QueryResponse} from './types';
Expand Down Expand Up @@ -56,7 +56,7 @@ export class VectorQuery<
*/
constructor(
private readonly _query: Query<AppModelType, DbModelType>,
private readonly _options: VectorQueryOptions
private readonly _options: FindNearestOptions
) {
this._queryUtil = new QueryUtil<
AppModelType,
Expand Down
2 changes: 1 addition & 1 deletion dev/system-test/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2538,7 +2538,7 @@ describe('Query class', () => {
expect(res.docs[0].get('distance')).to.equal(1);
});

it.only('supports select queries', async () => {
it('supports select queries', async () => {
const indexTestHelper = new IndexTestHelper(firestore);

const collectionReference = await indexTestHelper.setTestDocs({
Expand Down
6 changes: 3 additions & 3 deletions types/firestore.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2091,10 +2091,10 @@ declare namespace FirebaseFirestore {
* querySnapshot.forEach(...);
* ```
* @param options - An argument specifying the behavior of the {@link VectorQuery} returned by this function.
* See {@link VectorQueryOptions}.
* See {@link FindNearestOptions}.
*/
findNearest(
options: VectorQueryOptions
options: FindNearestOptions
): VectorQuery<AppModelType, DbModelType>;

/**
Expand Down Expand Up @@ -3231,7 +3231,7 @@ declare namespace FirebaseFirestore {
/**
* Specifies the behavior of the {@link VectorQuery} generated by a call to {@link Query.findNearest}.
*/
export interface VectorQueryOptions {
export interface FindNearestOptions {
/**
* A string or {@link FieldPath} specifying the vector field to search on.
*/
Expand Down

0 comments on commit 33b1cf8

Please sign in to comment.