Skip to content

Instantly share code, notes, and snippets.

@nyeholt
Created January 18, 2022 03:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyeholt/47be9e689b069375215c96f8ee3f865f to your computer and use it in GitHub Desktop.
Save nyeholt/47be9e689b069375215c96f8ee3f865f to your computer and use it in GitHub Desktop.
diff --git a/src/ResultList.php b/src/ResultList.php
index f941340..aefd6d0 100644
--- a/src/ResultList.php
+++ b/src/ResultList.php
@@ -55,7 +55,7 @@ class ResultList extends ViewableData implements SS_List, Limitable
//If we are in live reading mode, only return published documents
if (Versioned::get_stage() == Versioned::LIVE) {
- $publishedFilter = new Query\BoolQuery();
+ $publishedFilter = $query->hasParam('post_filter') ? $query->getParam('post_filter') : new Query\BoolQuery();
$publishedFilter->addMust(new Query\Term([Searchable::PUBLISHED_FIELD => true]));
$query->setPostFilter($publishedFilter);
}
@@ -120,6 +120,8 @@ class ResultList extends ViewableData implements SS_List, Limitable
} catch (Exception $e) {
if ($this->logger) {
$this->logger->critical($e->getMessage());
+ } else {
+ throw $e;
}
}
}
@@ -231,9 +233,12 @@ class ResultList extends ViewableData implements SS_List, Limitable
$highlightsArray[$field] = $concatenatedValue;
}
- //add Highlights property
- $retrieved[$type][$id]->highlights = new ArrayData($highlightsArray);
- $this->resultsArray[] = $retrieved[$type][$id];
+ //add Highlights property and score
+ $dataObj = $retrieved[$type][$id];
+ $dataObj->highlights = new ArrayData($highlightsArray);
+ $dataObj->QueryScore = $item->getScore();
+
+ $this->resultsArray[] = $dataObj;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment