]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/SearchRunner.php
Fixed occurances of altered titles in search results
[bookstack] / app / Entities / Tools / SearchRunner.php
index 3bcd6c0549838a9d5163878bc477e4ba68e30ca9..f6da871f49be5af2b7c664b938413c70ca302459 100644 (file)
@@ -141,13 +141,13 @@ class SearchRunner
         $relations = ['tags'];
 
         if ($entityModelInstance instanceof BookChild) {
-            $relations['book'] = function(BelongsTo $query) {
+            $relations['book'] = function (BelongsTo $query) {
                 $query->visible();
             };
         }
 
         if ($entityModelInstance instanceof Page) {
-            $relations['chapter'] = function(BelongsTo $query) {
+            $relations['chapter'] = function (BelongsTo $query) {
                 $query->visible();
             };
         }
@@ -237,6 +237,8 @@ class SearchRunner
      * Create a select statement, with prepared bindings, for the given
      * set of scored search terms.
      *
+     * @param array<string, float> $scoredTerms
+     *
      * @return array{statement: string, bindings: string[]}
      */
     protected function selectForScoredTerms(array $scoredTerms): array
@@ -258,6 +260,13 @@ class SearchRunner
         ];
     }
 
+    /**
+     * For the terms in the given search options, query their popularity across all
+     * search terms then provide that back as score adjustment multiplier applicable
+     * for their rarity. Returns an array of float multipliers, keyed by term.
+     *
+     * @return array<string, float>
+     */
     protected function getTermAdjustments(SearchOptions $options): array
     {
         if (isset($this->termAdjustmentCache[$options])) {
@@ -301,7 +310,7 @@ class SearchRunner
         if (empty($termCounts)) {
             return [];
         }
-        
+
         $multipliers = [];
         $max = max(array_values($termCounts));