SearchHitResource.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Http\Resources\V3;
  3. use Illuminate\Http\Request;
  4. /**
  5. * 一条检索命中(OpenSearch 文档归一化后的结构,见 `App\Services\V3\SearchService::hit()`)。
  6. *
  7. * `related_id` 对经文段落是 `{book}-{para}` 坐标;`display` 只在按 id 取单条时才有(阅读用的 HTML)。
  8. */
  9. class SearchHitResource extends BaseResource
  10. {
  11. /**
  12. * @return array{
  13. * id: string,
  14. * resource_type: string,
  15. * resource_id: string|null,
  16. * granularity: string|null,
  17. * language: string|null,
  18. * related_id: string|null,
  19. * score: float|null,
  20. * title: string,
  21. * content: string,
  22. * highlight: string|null,
  23. * bold: list<string>,
  24. * path: string|null,
  25. * category: list<string>,
  26. * tags: list<string>,
  27. * updated_at: string|null,
  28. * display?: string
  29. * }
  30. */
  31. public function toArray(Request $request): array
  32. {
  33. return $this->resource;
  34. }
  35. }