Navigation

Search

fulltext_search::searchSort

Description

Callback for usort used to sort the search results.

Syntax

int fulltext_search::searchSort (string $a, string $b)



Parameter $a

Expected type: String
Description: A search term to compare



Parameter $b

Expected type: String
Description: Another search term to compare to the first one



Return value

Expected type: Enumerated Integer
Description:

Possible integer values
Allowed values Description
-1 $b has a higher weight than $a
0 $a and $b have equal weight
1 $a has a higher weight than $b


Notes

  • Sorts larger words before smaller words
  • Sorts words that are included in the search before those that aren't
  • Compares the length of the two words
  • Weight is determined by finding the length of the word and subtracting 1000 if it's in the array of excluded terms
View all versions of this function