如何为getProductSearchResults()设置结果编号?

时间:2019-02-18 17:12:37

标签: php google-cloud-vision

此代码始终返回10条记录,谁知道如何设置100条记录?

可用于Google Cloud Vision产品搜索的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();

            }
        }

1 个答案:

答案 0 :(得分:0)

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