@google-cloud/discoveryengine 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -579,6 +579,99 @@ class SearchServiceClient {
579
579
  * This feature is not supported for healthcare search.
580
580
  * @param {google.cloud.discoveryengine.v1.SearchRequest.RelevanceScoreSpec} [request.relevanceScoreSpec]
581
581
  * Optional. The specification for returning the relevance score.
582
+ * @param {string} request.rankingExpression
583
+ * The ranking expression controls the customized ranking on retrieval
584
+ * documents. This overrides
585
+ * {@link protos.google.cloud.discoveryengine.v1.ServingConfig.ranking_expression|ServingConfig.ranking_expression}.
586
+ * The syntax and supported features depend on the
587
+ * `ranking_expression_backend` value. If `ranking_expression_backend` is not
588
+ * provided, it defaults to `RANK_BY_EMBEDDING`.
589
+ *
590
+ * If
591
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
592
+ * is not provided or set to `RANK_BY_EMBEDDING`, it should be a single
593
+ * function or multiple functions that are joined by "+".
594
+ *
595
+ * * ranking_expression = function, { " + ", function };
596
+ *
597
+ * Supported functions:
598
+ *
599
+ * * double * relevance_score
600
+ * * double * dotProduct(embedding_field_path)
601
+ *
602
+ * Function variables:
603
+ *
604
+ * * `relevance_score`: pre-defined keywords, used for measure relevance
605
+ * between query and document.
606
+ * * `embedding_field_path`: the document embedding field
607
+ * used with query embedding vector.
608
+ * * `dotProduct`: embedding function between `embedding_field_path` and
609
+ * query embedding vector.
610
+ *
611
+ * Example ranking expression:
612
+ *
613
+ * If document has an embedding field doc_embedding, the ranking expression
614
+ * could be `0.5 * relevance_score + 0.3 * dotProduct(doc_embedding)`.
615
+ *
616
+ * If
617
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
618
+ * is set to `RANK_BY_FORMULA`, the following expression types (and
619
+ * combinations of those chained using + or
620
+ * * operators) are supported:
621
+ *
622
+ * * `double`
623
+ * * `signal`
624
+ * * `log(signal)`
625
+ * * `exp(signal)`
626
+ * * `rr(signal, double > 0)` -- reciprocal rank transformation with second
627
+ * argument being a denominator constant.
628
+ * * `is_nan(signal)` -- returns 0 if signal is NaN, 1 otherwise.
629
+ * * `fill_nan(signal1, signal2 | double)` -- if signal1 is NaN, returns
630
+ * signal2 | double, else returns signal1.
631
+ *
632
+ * Here are a few examples of ranking formulas that use the supported
633
+ * ranking expression types:
634
+ *
635
+ * - `0.2 * semantic_similarity_score + 0.8 * log(keyword_similarity_score)`
636
+ * -- mostly rank by the logarithm of `keyword_similarity_score` with slight
637
+ * `semantic_smilarity_score` adjustment.
638
+ * - `0.2 * exp(fill_nan(semantic_similarity_score, 0)) + 0.3 *
639
+ * is_nan(keyword_similarity_score)` -- rank by the exponent of
640
+ * `semantic_similarity_score` filling the value with 0 if it's NaN, also
641
+ * add constant 0.3 adjustment to the final score if
642
+ * `semantic_similarity_score` is NaN.
643
+ * - `0.2 * rr(semantic_similarity_score, 16) + 0.8 *
644
+ * rr(keyword_similarity_score, 16)` -- mostly rank by the reciprocal rank
645
+ * of `keyword_similarity_score` with slight adjustment of reciprocal rank
646
+ * of `semantic_smilarity_score`.
647
+ *
648
+ * The following signals are supported:
649
+ *
650
+ * * `semantic_similarity_score`: semantic similarity adjustment that is
651
+ * calculated using the embeddings generated by a proprietary Google model.
652
+ * This score determines how semantically similar a search query is to a
653
+ * document.
654
+ * * `keyword_similarity_score`: keyword match adjustment uses the Best
655
+ * Match 25 (BM25) ranking function. This score is calculated using a
656
+ * probabilistic model to estimate the probability that a document is
657
+ * relevant to a given query.
658
+ * * `relevance_score`: semantic relevance adjustment that uses a
659
+ * proprietary Google model to determine the meaning and intent behind a
660
+ * user's query in context with the content in the documents.
661
+ * * `pctr_rank`: predicted conversion rate adjustment as a rank use
662
+ * predicted Click-through rate (pCTR) to gauge the relevance and
663
+ * attractiveness of a search result from a user's perspective. A higher
664
+ * pCTR suggests that the result is more likely to satisfy the user's query
665
+ * and intent, making it a valuable signal for ranking.
666
+ * * `freshness_rank`: freshness adjustment as a rank
667
+ * * `document_age`: The time in hours elapsed since the document was last
668
+ * updated, a floating-point number (e.g., 0.25 means 15 minutes).
669
+ * * `topicality_rank`: topicality adjustment as a rank. Uses proprietary
670
+ * Google model to determine the keyword-based overlap between the query and
671
+ * the document.
672
+ * * `base_rank`: the default rank of the result
673
+ * @param {google.cloud.discoveryengine.v1.SearchRequest.RankingExpressionBackend} [request.rankingExpressionBackend]
674
+ * The backend to use for the ranking expression evaluation.
582
675
  * @param {object} [options]
583
676
  * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
584
677
  * @returns {Stream}
@@ -831,6 +924,99 @@ class SearchServiceClient {
831
924
  * This feature is not supported for healthcare search.
832
925
  * @param {google.cloud.discoveryengine.v1.SearchRequest.RelevanceScoreSpec} [request.relevanceScoreSpec]
833
926
  * Optional. The specification for returning the relevance score.
927
+ * @param {string} request.rankingExpression
928
+ * The ranking expression controls the customized ranking on retrieval
929
+ * documents. This overrides
930
+ * {@link protos.google.cloud.discoveryengine.v1.ServingConfig.ranking_expression|ServingConfig.ranking_expression}.
931
+ * The syntax and supported features depend on the
932
+ * `ranking_expression_backend` value. If `ranking_expression_backend` is not
933
+ * provided, it defaults to `RANK_BY_EMBEDDING`.
934
+ *
935
+ * If
936
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
937
+ * is not provided or set to `RANK_BY_EMBEDDING`, it should be a single
938
+ * function or multiple functions that are joined by "+".
939
+ *
940
+ * * ranking_expression = function, { " + ", function };
941
+ *
942
+ * Supported functions:
943
+ *
944
+ * * double * relevance_score
945
+ * * double * dotProduct(embedding_field_path)
946
+ *
947
+ * Function variables:
948
+ *
949
+ * * `relevance_score`: pre-defined keywords, used for measure relevance
950
+ * between query and document.
951
+ * * `embedding_field_path`: the document embedding field
952
+ * used with query embedding vector.
953
+ * * `dotProduct`: embedding function between `embedding_field_path` and
954
+ * query embedding vector.
955
+ *
956
+ * Example ranking expression:
957
+ *
958
+ * If document has an embedding field doc_embedding, the ranking expression
959
+ * could be `0.5 * relevance_score + 0.3 * dotProduct(doc_embedding)`.
960
+ *
961
+ * If
962
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
963
+ * is set to `RANK_BY_FORMULA`, the following expression types (and
964
+ * combinations of those chained using + or
965
+ * * operators) are supported:
966
+ *
967
+ * * `double`
968
+ * * `signal`
969
+ * * `log(signal)`
970
+ * * `exp(signal)`
971
+ * * `rr(signal, double > 0)` -- reciprocal rank transformation with second
972
+ * argument being a denominator constant.
973
+ * * `is_nan(signal)` -- returns 0 if signal is NaN, 1 otherwise.
974
+ * * `fill_nan(signal1, signal2 | double)` -- if signal1 is NaN, returns
975
+ * signal2 | double, else returns signal1.
976
+ *
977
+ * Here are a few examples of ranking formulas that use the supported
978
+ * ranking expression types:
979
+ *
980
+ * - `0.2 * semantic_similarity_score + 0.8 * log(keyword_similarity_score)`
981
+ * -- mostly rank by the logarithm of `keyword_similarity_score` with slight
982
+ * `semantic_smilarity_score` adjustment.
983
+ * - `0.2 * exp(fill_nan(semantic_similarity_score, 0)) + 0.3 *
984
+ * is_nan(keyword_similarity_score)` -- rank by the exponent of
985
+ * `semantic_similarity_score` filling the value with 0 if it's NaN, also
986
+ * add constant 0.3 adjustment to the final score if
987
+ * `semantic_similarity_score` is NaN.
988
+ * - `0.2 * rr(semantic_similarity_score, 16) + 0.8 *
989
+ * rr(keyword_similarity_score, 16)` -- mostly rank by the reciprocal rank
990
+ * of `keyword_similarity_score` with slight adjustment of reciprocal rank
991
+ * of `semantic_smilarity_score`.
992
+ *
993
+ * The following signals are supported:
994
+ *
995
+ * * `semantic_similarity_score`: semantic similarity adjustment that is
996
+ * calculated using the embeddings generated by a proprietary Google model.
997
+ * This score determines how semantically similar a search query is to a
998
+ * document.
999
+ * * `keyword_similarity_score`: keyword match adjustment uses the Best
1000
+ * Match 25 (BM25) ranking function. This score is calculated using a
1001
+ * probabilistic model to estimate the probability that a document is
1002
+ * relevant to a given query.
1003
+ * * `relevance_score`: semantic relevance adjustment that uses a
1004
+ * proprietary Google model to determine the meaning and intent behind a
1005
+ * user's query in context with the content in the documents.
1006
+ * * `pctr_rank`: predicted conversion rate adjustment as a rank use
1007
+ * predicted Click-through rate (pCTR) to gauge the relevance and
1008
+ * attractiveness of a search result from a user's perspective. A higher
1009
+ * pCTR suggests that the result is more likely to satisfy the user's query
1010
+ * and intent, making it a valuable signal for ranking.
1011
+ * * `freshness_rank`: freshness adjustment as a rank
1012
+ * * `document_age`: The time in hours elapsed since the document was last
1013
+ * updated, a floating-point number (e.g., 0.25 means 15 minutes).
1014
+ * * `topicality_rank`: topicality adjustment as a rank. Uses proprietary
1015
+ * Google model to determine the keyword-based overlap between the query and
1016
+ * the document.
1017
+ * * `base_rank`: the default rank of the result
1018
+ * @param {google.cloud.discoveryengine.v1.SearchRequest.RankingExpressionBackend} [request.rankingExpressionBackend]
1019
+ * The backend to use for the ranking expression evaluation.
834
1020
  * @param {object} [options]
835
1021
  * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
836
1022
  * @returns {Object}
@@ -1113,6 +1299,99 @@ class SearchServiceClient {
1113
1299
  * This feature is not supported for healthcare search.
1114
1300
  * @param {google.cloud.discoveryengine.v1.SearchRequest.RelevanceScoreSpec} [request.relevanceScoreSpec]
1115
1301
  * Optional. The specification for returning the relevance score.
1302
+ * @param {string} request.rankingExpression
1303
+ * The ranking expression controls the customized ranking on retrieval
1304
+ * documents. This overrides
1305
+ * {@link protos.google.cloud.discoveryengine.v1.ServingConfig.ranking_expression|ServingConfig.ranking_expression}.
1306
+ * The syntax and supported features depend on the
1307
+ * `ranking_expression_backend` value. If `ranking_expression_backend` is not
1308
+ * provided, it defaults to `RANK_BY_EMBEDDING`.
1309
+ *
1310
+ * If
1311
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
1312
+ * is not provided or set to `RANK_BY_EMBEDDING`, it should be a single
1313
+ * function or multiple functions that are joined by "+".
1314
+ *
1315
+ * * ranking_expression = function, { " + ", function };
1316
+ *
1317
+ * Supported functions:
1318
+ *
1319
+ * * double * relevance_score
1320
+ * * double * dotProduct(embedding_field_path)
1321
+ *
1322
+ * Function variables:
1323
+ *
1324
+ * * `relevance_score`: pre-defined keywords, used for measure relevance
1325
+ * between query and document.
1326
+ * * `embedding_field_path`: the document embedding field
1327
+ * used with query embedding vector.
1328
+ * * `dotProduct`: embedding function between `embedding_field_path` and
1329
+ * query embedding vector.
1330
+ *
1331
+ * Example ranking expression:
1332
+ *
1333
+ * If document has an embedding field doc_embedding, the ranking expression
1334
+ * could be `0.5 * relevance_score + 0.3 * dotProduct(doc_embedding)`.
1335
+ *
1336
+ * If
1337
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
1338
+ * is set to `RANK_BY_FORMULA`, the following expression types (and
1339
+ * combinations of those chained using + or
1340
+ * * operators) are supported:
1341
+ *
1342
+ * * `double`
1343
+ * * `signal`
1344
+ * * `log(signal)`
1345
+ * * `exp(signal)`
1346
+ * * `rr(signal, double > 0)` -- reciprocal rank transformation with second
1347
+ * argument being a denominator constant.
1348
+ * * `is_nan(signal)` -- returns 0 if signal is NaN, 1 otherwise.
1349
+ * * `fill_nan(signal1, signal2 | double)` -- if signal1 is NaN, returns
1350
+ * signal2 | double, else returns signal1.
1351
+ *
1352
+ * Here are a few examples of ranking formulas that use the supported
1353
+ * ranking expression types:
1354
+ *
1355
+ * - `0.2 * semantic_similarity_score + 0.8 * log(keyword_similarity_score)`
1356
+ * -- mostly rank by the logarithm of `keyword_similarity_score` with slight
1357
+ * `semantic_smilarity_score` adjustment.
1358
+ * - `0.2 * exp(fill_nan(semantic_similarity_score, 0)) + 0.3 *
1359
+ * is_nan(keyword_similarity_score)` -- rank by the exponent of
1360
+ * `semantic_similarity_score` filling the value with 0 if it's NaN, also
1361
+ * add constant 0.3 adjustment to the final score if
1362
+ * `semantic_similarity_score` is NaN.
1363
+ * - `0.2 * rr(semantic_similarity_score, 16) + 0.8 *
1364
+ * rr(keyword_similarity_score, 16)` -- mostly rank by the reciprocal rank
1365
+ * of `keyword_similarity_score` with slight adjustment of reciprocal rank
1366
+ * of `semantic_smilarity_score`.
1367
+ *
1368
+ * The following signals are supported:
1369
+ *
1370
+ * * `semantic_similarity_score`: semantic similarity adjustment that is
1371
+ * calculated using the embeddings generated by a proprietary Google model.
1372
+ * This score determines how semantically similar a search query is to a
1373
+ * document.
1374
+ * * `keyword_similarity_score`: keyword match adjustment uses the Best
1375
+ * Match 25 (BM25) ranking function. This score is calculated using a
1376
+ * probabilistic model to estimate the probability that a document is
1377
+ * relevant to a given query.
1378
+ * * `relevance_score`: semantic relevance adjustment that uses a
1379
+ * proprietary Google model to determine the meaning and intent behind a
1380
+ * user's query in context with the content in the documents.
1381
+ * * `pctr_rank`: predicted conversion rate adjustment as a rank use
1382
+ * predicted Click-through rate (pCTR) to gauge the relevance and
1383
+ * attractiveness of a search result from a user's perspective. A higher
1384
+ * pCTR suggests that the result is more likely to satisfy the user's query
1385
+ * and intent, making it a valuable signal for ranking.
1386
+ * * `freshness_rank`: freshness adjustment as a rank
1387
+ * * `document_age`: The time in hours elapsed since the document was last
1388
+ * updated, a floating-point number (e.g., 0.25 means 15 minutes).
1389
+ * * `topicality_rank`: topicality adjustment as a rank. Uses proprietary
1390
+ * Google model to determine the keyword-based overlap between the query and
1391
+ * the document.
1392
+ * * `base_rank`: the default rank of the result
1393
+ * @param {google.cloud.discoveryengine.v1.SearchRequest.RankingExpressionBackend} [request.rankingExpressionBackend]
1394
+ * The backend to use for the ranking expression evaluation.
1116
1395
  * @param {object} [options]
1117
1396
  * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1118
1397
  * @returns {Stream}
@@ -1365,6 +1644,99 @@ class SearchServiceClient {
1365
1644
  * This feature is not supported for healthcare search.
1366
1645
  * @param {google.cloud.discoveryengine.v1.SearchRequest.RelevanceScoreSpec} [request.relevanceScoreSpec]
1367
1646
  * Optional. The specification for returning the relevance score.
1647
+ * @param {string} request.rankingExpression
1648
+ * The ranking expression controls the customized ranking on retrieval
1649
+ * documents. This overrides
1650
+ * {@link protos.google.cloud.discoveryengine.v1.ServingConfig.ranking_expression|ServingConfig.ranking_expression}.
1651
+ * The syntax and supported features depend on the
1652
+ * `ranking_expression_backend` value. If `ranking_expression_backend` is not
1653
+ * provided, it defaults to `RANK_BY_EMBEDDING`.
1654
+ *
1655
+ * If
1656
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
1657
+ * is not provided or set to `RANK_BY_EMBEDDING`, it should be a single
1658
+ * function or multiple functions that are joined by "+".
1659
+ *
1660
+ * * ranking_expression = function, { " + ", function };
1661
+ *
1662
+ * Supported functions:
1663
+ *
1664
+ * * double * relevance_score
1665
+ * * double * dotProduct(embedding_field_path)
1666
+ *
1667
+ * Function variables:
1668
+ *
1669
+ * * `relevance_score`: pre-defined keywords, used for measure relevance
1670
+ * between query and document.
1671
+ * * `embedding_field_path`: the document embedding field
1672
+ * used with query embedding vector.
1673
+ * * `dotProduct`: embedding function between `embedding_field_path` and
1674
+ * query embedding vector.
1675
+ *
1676
+ * Example ranking expression:
1677
+ *
1678
+ * If document has an embedding field doc_embedding, the ranking expression
1679
+ * could be `0.5 * relevance_score + 0.3 * dotProduct(doc_embedding)`.
1680
+ *
1681
+ * If
1682
+ * {@link protos.google.cloud.discoveryengine.v1.SearchRequest.ranking_expression_backend|ranking_expression_backend}
1683
+ * is set to `RANK_BY_FORMULA`, the following expression types (and
1684
+ * combinations of those chained using + or
1685
+ * * operators) are supported:
1686
+ *
1687
+ * * `double`
1688
+ * * `signal`
1689
+ * * `log(signal)`
1690
+ * * `exp(signal)`
1691
+ * * `rr(signal, double > 0)` -- reciprocal rank transformation with second
1692
+ * argument being a denominator constant.
1693
+ * * `is_nan(signal)` -- returns 0 if signal is NaN, 1 otherwise.
1694
+ * * `fill_nan(signal1, signal2 | double)` -- if signal1 is NaN, returns
1695
+ * signal2 | double, else returns signal1.
1696
+ *
1697
+ * Here are a few examples of ranking formulas that use the supported
1698
+ * ranking expression types:
1699
+ *
1700
+ * - `0.2 * semantic_similarity_score + 0.8 * log(keyword_similarity_score)`
1701
+ * -- mostly rank by the logarithm of `keyword_similarity_score` with slight
1702
+ * `semantic_smilarity_score` adjustment.
1703
+ * - `0.2 * exp(fill_nan(semantic_similarity_score, 0)) + 0.3 *
1704
+ * is_nan(keyword_similarity_score)` -- rank by the exponent of
1705
+ * `semantic_similarity_score` filling the value with 0 if it's NaN, also
1706
+ * add constant 0.3 adjustment to the final score if
1707
+ * `semantic_similarity_score` is NaN.
1708
+ * - `0.2 * rr(semantic_similarity_score, 16) + 0.8 *
1709
+ * rr(keyword_similarity_score, 16)` -- mostly rank by the reciprocal rank
1710
+ * of `keyword_similarity_score` with slight adjustment of reciprocal rank
1711
+ * of `semantic_smilarity_score`.
1712
+ *
1713
+ * The following signals are supported:
1714
+ *
1715
+ * * `semantic_similarity_score`: semantic similarity adjustment that is
1716
+ * calculated using the embeddings generated by a proprietary Google model.
1717
+ * This score determines how semantically similar a search query is to a
1718
+ * document.
1719
+ * * `keyword_similarity_score`: keyword match adjustment uses the Best
1720
+ * Match 25 (BM25) ranking function. This score is calculated using a
1721
+ * probabilistic model to estimate the probability that a document is
1722
+ * relevant to a given query.
1723
+ * * `relevance_score`: semantic relevance adjustment that uses a
1724
+ * proprietary Google model to determine the meaning and intent behind a
1725
+ * user's query in context with the content in the documents.
1726
+ * * `pctr_rank`: predicted conversion rate adjustment as a rank use
1727
+ * predicted Click-through rate (pCTR) to gauge the relevance and
1728
+ * attractiveness of a search result from a user's perspective. A higher
1729
+ * pCTR suggests that the result is more likely to satisfy the user's query
1730
+ * and intent, making it a valuable signal for ranking.
1731
+ * * `freshness_rank`: freshness adjustment as a rank
1732
+ * * `document_age`: The time in hours elapsed since the document was last
1733
+ * updated, a floating-point number (e.g., 0.25 means 15 minutes).
1734
+ * * `topicality_rank`: topicality adjustment as a rank. Uses proprietary
1735
+ * Google model to determine the keyword-based overlap between the query and
1736
+ * the document.
1737
+ * * `base_rank`: the default rank of the result
1738
+ * @param {google.cloud.discoveryengine.v1.SearchRequest.RankingExpressionBackend} [request.rankingExpressionBackend]
1739
+ * The backend to use for the ranking expression evaluation.
1368
1740
  * @param {object} [options]
1369
1741
  * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
1370
1742
  * @returns {Object}