【问题标题】:how I can set the result number for getProductSearchResults()?如何设置 getProductSearchResults() 的结果编号?
【发布时间】:2019-07-12 03:07:22
【问题描述】:

这段代码总是返回10条记录,有谁知道如何设置100条?

用于使用 Google Cloud Vision Product Search 的 API。

 # get the name of the product set

 $productSetPath = $productSearchClient->productSetName($projectId, $location, $productSetId);

        # product search specific parameters
        $productSearchParams = (new ProductSearchParams())
            ->setProductSet($productSetPath)
            ->setProductCategories([$productCategory]);

        # search products similar to the image
        $response = $imageAnnotatorClient->productSearch($image, $productSearchParams);

        if ($productSearchResults = $response->getProductSearchResults()) {

            $results = $productSearchResults->getResults(); //this always return 10 results. 

            foreach ($results as $result) {

                # display the product information.
                $product = $result->getProduct();
                $productName = $product->getName();

            }
        }

【问题讨论】:

  • 使用 google 和文档 30 秒后,我建议查看 public ProductSearchParams setBoundingPoly(BoundingPoly boundingPoly) 以增加查找结果的边界

标签: php google-cloud-platform google-cloud-vision


【解决方案1】:

productSearchParams中没有地方可以指定产品搜索结果的数量。 BoundingPoly 与结果的数量无关。 BoundingPoly 是一个可选参数,用于标记包含产品的图像区域。

【讨论】:

    猜你喜欢
    • 2014-11-10
    • 2017-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-24
    • 2017-06-28
    • 1970-01-01
    • 2016-02-18
    相关资源
    最近更新 更多