Overview

Namespaces

  • PHP
  • vierbergenlars
    • Forage
      • ODM
        • HydrationSettings
      • QueryParser
      • SearchIndex
      • SearchQuery
      • SearchResult
      • Transport

Classes

  • Facet
  • Hit
  • SearchResult
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace vierbergenlars\Forage\SearchResult;
 4: 
 5: /**
 6:  * A search hit
 7:  */
 8: class Hit
 9: {
10:     /**
11:      * The id of the document that matched
12:      *
13:      * @var string|int
14:      */
15:     protected $id;
16: 
17:     /**
18:      * The terms that matched in the document
19:      *
20:      * @var array
21:      */
22:     protected $matchedTerms;
23: 
24:     /**
25:      * The matched document
26:      *
27:      * @var array
28:      */
29:     protected $document;
30: 
31:     /**
32:      * The result score for the document
33:      * @var float
34:      */
35:     protected $score;
36: 
37:     /**
38:      * Creates a new hit object
39:      *
40:      * @private
41:      * @param array $hit_array
42:      */
43:     public function __construct(array $hit_array)
44:     {
45:         $this->id = $hit_array['id'];
46:         $this->matchedTerms = $hit_array['matchedTerms'];
47:         $this->document = $hit_array['document'];
48:         $this->score = $hit_array['score'];
49:     }
50: 
51:     /**
52:      * Gets the score of the document for the search query
53:      * @return float
54:      */
55:     public function getScore()
56:     {
57:         return $this->score;
58:     }
59: 
60:     /**
61:      * Gets the terms that matched in the document
62:      *
63:      * @return array
64:      */
65:     public function getMatchedTerms()
66:     {
67:         return $this->matchedTerms;
68:     }
69: 
70:     /**
71:      * Gets the document
72:      *
73:      * @return array
74:      */
75:     public function getDocument()
76:     {
77:         return $this->document;
78:     }
79: 
80:     /**
81:      * Gets the id of the document
82:      *
83:      * @return string|int
84:      */
85:     public function getId()
86:     {
87:         return $this->id;
88:     }
89: }
90: 
Forage-PHP-Client API documentation generated by ApiGen 2.8.0