PrefixSearch: Enforce including the exact match as first result
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 17 Sep 2014 23:24:41 +0000 (16:24 -0700)
committerKrinkle <krinklemail@gmail.com>
Fri, 10 Oct 2014 19:32:09 +0000 (19:32 +0000)
commit8dd95a13e31af2116eca5edda275acb499c40316
treeaccbde7c555da4653f78e87f2a04a6e015921842
parent9e3e9e28d4f9d77e50e92f6feb834c50caa7dd41
PrefixSearch: Enforce including the exact match as first result

The default search backend implements proper prefix search and
does this naturally. But extensions providing search backends
like Lucene and CirrusSearch actually fail to implement proper
prefix searching and instead use their search engine ranking for
prefix search as well. Thus often the exact match is not on top
or is not even in the first 10 results at all.

On en.wikipedia.org:

> Example
1. "Example (musician)"
2. "Example"
3. "Example.com"

> John ive
1. "John Ives"
2. "John Ivey"
3. "John Ive"

> Foo
1. "Football (soccer)"
2. "Football League Cup"
3. "Foot (length)"

"Foo" exists but is NOT among the returned results.

Bug: 70958
Change-Id: I78d419424baf43d38beeb6dabfc347f430fa45f6
includes/PrefixSearch.php
tests/phpunit/includes/PrefixSearchTest.php