/**
* Get current search rank.
*
- * The higher the search rank the lower the likelyhood that the
+ * The higher the search rank the lower the likelihood that the
* search is a correct interpretation of the search query.
*
* @return integer Search rank.
$iOp = Operator::NEAR; // near == in for the moment
if ($aSearchTerm['operator'] == '') {
- if (sizeof($this->aName)) {
+ if (sizeof($this->aName) || $this->oContext->isBoundedSearch()) {
$iOp = Operator::NAME;
}
$oSearch->iSearchRank += 2;
$this->aFullNameAddress[$iWordID] = $iWordID;
}
} else {
- $oSearch = clone $this;
- $oSearch->iSearchRank++;
- $oSearch->aName = array($iWordID => $iWordID);
- $aNewSearches[] = $oSearch;
+ // in structured search only the first phrase can be the
+ // designated name
+ if ($sPhraseType == '' || $bFirstPhrase) {
+ $oSearch = clone $this;
+ $oSearch->iSearchRank++;
+ $oSearch->aName = array($iWordID => $iWordID);
+ $aNewSearches[] = $oSearch;
+ }
}
}
) {
if ($aSearchTerm['search_name_count'] + 1 < CONST_Max_Word_Frequency) {
$oSearch = clone $this;
- $oSearch->iSearchRank++;
+ $oSearch->iSearchRank += 2;
$oSearch->aAddress[$iWordID] = $iWordID;
$aNewSearches[] = $oSearch;
} else {
&& (!sizeof($this->aName) || $this->iNamePhrase == $iPhrase)
) {
$oSearch = clone $this;
- $oSearch->iSearchRank++;
+ $oSearch->iSearchRank += 2;
if (!sizeof($this->aName)) {
$oSearch->iSearchRank += 1;
}
if ($this->sHouseNumber) {
$sImportanceSQL = '- abs(26 - address_rank) + 3';
} else {
- $sImportanceSQL = '(CASE WHEN importance = 0 OR importance IS NULL THEN 0.75-(search_rank::float/40) ELSE importance END)';
+ $sImportanceSQL = '(CASE WHEN importance = 0 OR importance IS NULL THEN 0.75001-(search_rank::float/40) ELSE importance END)';
}
$sImportanceSQL .= $this->oContext->viewboxImportanceSQL('centroid');
$aOrder[] = "$sImportanceSQL DESC";