@@ -1208,7 +1208,7 @@ export abstract class Expr implements ProtoValueSerializable, UserData {
1208
1208
...others : Array < Expr | unknown >
1209
1209
) : FunctionExpr {
1210
1210
const values = [ second , ...others ] ;
1211
- return new FunctionExpr ( 'logical_min ' , [
1211
+ return new FunctionExpr ( 'logical_minimum ' , [
1212
1212
this ,
1213
1213
...values . map ( valueToDefaultExpr )
1214
1214
] ) ;
@@ -1314,39 +1314,6 @@ export abstract class Expr implements ProtoValueSerializable, UserData {
1314
1314
return new FunctionExpr ( 'euclidean_distance' , [ this , vectorToExpr ( other ) ] ) ;
1315
1315
}
1316
1316
1317
- /**
1318
- * @beta
1319
- *
1320
- * Calculates the Manhattan distance between the result of this expression and another VectorValue.
1321
- *
1322
- * ```typescript
1323
- * // Calculate the Manhattan distance between the 'location' field and a target location
1324
- * field("location").manhattanDistance(new VectorValue([37.7749, -122.4194]));
1325
- * ```
1326
- *
1327
- * @param vector The other vector (as a VectorValue) to compare against.
1328
- * @return A new {@code Expr} representing the Manhattan distance between the two vectors.
1329
- */
1330
- manhattanDistance ( vector : VectorValue | number [ ] ) : FunctionExpr ;
1331
-
1332
- /**
1333
- * @beta
1334
- *
1335
- * Calculates the Manhattan distance between two vector expressions.
1336
- *
1337
- * ```typescript
1338
- * // Calculate the Manhattan distance between two vector fields: 'pointA' and 'pointB'
1339
- * field("pointA").manhattanDistance(field("pointB"));
1340
- * ```
1341
- *
1342
- * @param vectorExpression The other vector (represented as an Expr) to compare against.
1343
- * @return A new {@code Expr} representing the Manhattan distance between the two vectors.
1344
- */
1345
- manhattanDistance ( vectorExpression : Expr ) : FunctionExpr ;
1346
- manhattanDistance ( other : Expr | number [ ] | VectorValue ) : FunctionExpr {
1347
- return new FunctionExpr ( 'manhattan_distance' , [ this , vectorToExpr ( other ) ] ) ;
1348
- }
1349
-
1350
1317
/**
1351
1318
* Creates an expression that interprets this expression as the number of microseconds since the Unix epoch (1970-01-01 00:00:00 UTC)
1352
1319
* and returns a timestamp.
@@ -2281,8 +2248,6 @@ export function field(nameOrPath: string | FieldPath): Field {
2281
2248
return new Field ( documentIdFieldPath ( ) . _internalPath ) ;
2282
2249
}
2283
2250
return new Field ( fieldPathFromArgument ( 'of' , nameOrPath ) ) ;
2284
- } else if ( documentIdFieldPath ( ) . isEqual ( nameOrPath ) ) {
2285
- return new Field ( documentIdFieldPath ( ) . _internalPath ) ;
2286
2251
} else {
2287
2252
return new Field ( nameOrPath . _internalPath ) ;
2288
2253
}
@@ -4611,6 +4576,21 @@ export function arrayContainsAll(
4611
4576
return fieldOfOrExpr ( array ) . arrayContainsAll ( values ) ;
4612
4577
}
4613
4578
4579
+ /**
4580
+ * @beta
4581
+ *
4582
+ * Creates an expression that calculates the length of an array in a specified field.
4583
+ *
4584
+ * ```typescript
4585
+ * // Get the number of items in field 'cart'
4586
+ * arrayLength('cart');
4587
+ * ```
4588
+ *
4589
+ * @param fieldName The name of the field containing an array to calculate the length of.
4590
+ * @return A new {@code Expr} representing the length of the array.
4591
+ */
4592
+ export function arrayLength ( fieldName : string ) : FunctionExpr ;
4593
+
4614
4594
/**
4615
4595
* @beta
4616
4596
*
@@ -4624,8 +4604,9 @@ export function arrayContainsAll(
4624
4604
* @param array The array expression to calculate the length of.
4625
4605
* @return A new {@code Expr} representing the length of the array.
4626
4606
*/
4627
- export function arrayLength ( array : Expr ) : FunctionExpr {
4628
- return array . arrayLength ( ) ;
4607
+ export function arrayLength ( array : Expr ) : FunctionExpr ;
4608
+ export function arrayLength ( array : Expr | string ) : FunctionExpr {
4609
+ return fieldOfOrExpr ( array ) . arrayLength ( ) ;
4629
4610
}
4630
4611
4631
4612
/**
@@ -5883,7 +5864,7 @@ export function strConcat(
5883
5864
second : string | Expr ,
5884
5865
...elements : Array < string | Expr >
5885
5866
) : FunctionExpr {
5886
- return valueToDefaultExpr ( first ) . strConcat (
5867
+ return fieldOfOrExpr ( first ) . strConcat (
5887
5868
valueToDefaultExpr ( second ) ,
5888
5869
...elements . map ( valueToDefaultExpr )
5889
5870
) ;
@@ -6366,91 +6347,6 @@ export function euclideanDistance(
6366
6347
return expr1 . euclideanDistance ( expr2 ) ;
6367
6348
}
6368
6349
6369
- /**
6370
- * @beta
6371
- *
6372
- * Calculates the Manhattan distance between a field's vector value and a double array.
6373
- *
6374
- * ```typescript
6375
- * // Calculate the Manhattan distance between the 'location' field and a target location
6376
- * manhattanDistance("location", [37.7749, -122.4194]);
6377
- * ```
6378
- *
6379
- * @param fieldName The name of the field containing the first vector.
6380
- * @param vector The other vector (as an array of doubles or VectorValue) to compare against.
6381
- * @return A new {@code Expr} representing the Manhattan distance between the two vectors.
6382
- */
6383
- export function manhattanDistance (
6384
- fieldName : string ,
6385
- vector : number [ ] | VectorValue
6386
- ) : FunctionExpr ;
6387
-
6388
- /**
6389
- * @beta
6390
- *
6391
- * Calculates the Manhattan distance between a field's vector value and a vector expression.
6392
- *
6393
- * ```typescript
6394
- * // Calculate the Manhattan distance between two vector fields: 'pointA' and 'pointB'
6395
- * manhattanDistance("pointA", field("pointB"));
6396
- * ```
6397
- *
6398
- * @param fieldName The name of the field containing the first vector.
6399
- * @param vectorExpression The other vector (represented as an Expr) to compare against.
6400
- * @return A new {@code Expr} representing the Manhattan distance between the two vectors.
6401
- */
6402
- export function manhattanDistance (
6403
- fieldName : string ,
6404
- vectorExpression : Expr
6405
- ) : FunctionExpr ;
6406
-
6407
- /**
6408
- * @beta
6409
- *
6410
- * Calculates the Manhattan distance between a vector expression and a double array.
6411
- *
6412
- * ```typescript
6413
- * // Calculate the Manhattan distance between the 'location' field and a target location
6414
- *
6415
- * manhattanDistance(field("location"), [37.7749, -122.4194]);
6416
- * ```
6417
- *
6418
- * @param vectorExpression The first vector (represented as an Expr) to compare against.
6419
- * @param vector The other vector (as an array of doubles or VectorValue) to compare against.
6420
- * @return A new {@code Expr} representing the Manhattan distance between the two vectors.
6421
- */
6422
- export function manhattanDistance (
6423
- vectorExpression : Expr ,
6424
- vector : number [ ] | VectorValue
6425
- ) : FunctionExpr ;
6426
-
6427
- /**
6428
- * @beta
6429
- *
6430
- * Calculates the Manhattan distance between two vector expressions.
6431
- *
6432
- * ```typescript
6433
- * // Calculate the Manhattan distance between two vector fields: 'pointA' and 'pointB'
6434
- * manhattanDistance(field("pointA"), field("pointB"));
6435
- * ```
6436
- *
6437
- * @param vectorExpression The first vector (represented as an Expr) to compare against.
6438
- * @param otherVectorExpression The other vector (represented as an Expr) to compare against.
6439
- * @return A new {@code Expr} representing the Manhattan distance between the two vectors.
6440
- */
6441
- export function manhattanDistance (
6442
- vectorExpression : Expr ,
6443
- otherVectorExpression : Expr
6444
- ) : FunctionExpr ;
6445
- export function manhattanDistance (
6446
- fieldOrExpr : Expr | string ,
6447
- other : Expr | number [ ] | VectorValue
6448
- ) : FunctionExpr {
6449
- const expr1 = fieldOfOrExpr ( fieldOrExpr ) ;
6450
- const expr2 = vectorToExpr ( other ) ;
6451
- return expr1 . manhattanDistance ( expr2 ) ;
6452
- }
6453
-
6454
6350
/**
6455
6351
* @beta
6456
6352
*
0 commit comments