SearchSuggestionResource.php 772 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace App\Http\Resources\V3;
  3. use Illuminate\Http\Request;
  4. /**
  5. * 一条搜索建议(OpenSearch completion 候选,见 `App\Services\V3\SearchService::suggest()`)。
  6. *
  7. * `source` 是候选来自哪个补全字段;`doc_id` 是候选所在的检索文档,可直接 `GET /v3/search/{doc_id}`。
  8. */
  9. class SearchSuggestionResource extends BaseResource
  10. {
  11. /**
  12. * @return array{
  13. * text: string,
  14. * source: string,
  15. * score: float,
  16. * doc_id: string|null,
  17. * resource_type: string|null,
  18. * language: string|null,
  19. * granularity: string|null,
  20. * category: list<string>
  21. * }
  22. */
  23. public function toArray(Request $request): array
  24. {
  25. return $this->resource;
  26. }
  27. }