Page MenuHomePhabricator

Optional search engines
Closed, InvalidPublic

Description

Author: meh

Description:
Allow for users to create alternate search engines. The method I'm using is to
modify index.php to make this:
require_once( 'includes/SpecialSearch.php' );
use a variable:
require_once( $wgSearchPage );

That I setup in LocalSettings.php:

  1. $wgSearchPage = "includes/SpecialSearch.php"; $wgSearchPage = "includes/SpecialGSearch.php";

The main function call remains the same, thus minimally affecting the scripts.

I'm creating a google-style syntax search with ranked results for the wikis that I
admin (I've already created, um... 4 or 5 of these for other projects? Something
like that...)


Version: unspecified
Severity: enhancement

Details

Reference
bz2252

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 8:30 PM
bzimport added a project: MediaWiki-Search.
bzimport set Reference to bz2252.
bzimport added a subscriber: Unknown Object (MLST).

river wrote:

you can already do this. look at extensions/LuceneSearch.php in CVS.

meh wrote:

Lucene doesn't handle phrases... but I'll try working with it first.

river wrote:

what is a search phrase? you can do whatever you want with the search term
provided to your search page - it's just another special page, plus
$wgDisableInternalSearch...

meh wrote:

"find this phrase" is a search phrase. If I use Lucene search on Wikipedia for this:

"san jose"

it will find anything with "san" or "jose" - including "San Francisco" or "sands of time"

If I use "san jose" on Google, it will only find pages with the words "san jose" next to each
other.

river wrote:

that's a function of the implementation of SpecialSearch, not something particular
to the page itself. if you don't want to use Lucene, you don't have to - as long
as your special page uses the same interface, it can do the search itself however
it wants.

I've already started reworking the SearchEngine backend in CVS HEAD. The new MWSearch
extension provides the Lucene backend for this working on the main frontend; you could do any
other sort of backend engine the same way.

(There will be a few additional tweaks to it to spiff up the frontend still.)

Second, I don't understand the claim about phrase search; the Lucene search *does* do phrase
searches when you quote them. I'm not sure whether the claim is actually about quoted phrase
searches or about the inclusive vs conjunctive search style; at the moment our Lucene search
defaults to 'or' searches so it will returns hits matching any of the given terms (where
terms may be words or quoted phrases) rather than requiring all of them. Since this is
generally annoying, it should at some point be fixed up as we did for the MySQL 4 boolean
fulltext search to require all terms to be present in matches. That however is totally and
completely unrelated to the request of this bug and I don't understand why it's been brought
up here.

meh wrote:

I wasn't being clear - I meant that the extension doesn't do phrase searching. It also doesn't
appear to do the type of ranking I'm attempting... and all of this is secondary to the
request - I was only looking for a way to extend the search by modifying only LocalSettings.
Creating my own search functionality is straightforward.

river wrote:

yes; you can do this already. create a special page and use it in local settings
like normal. look at LuceneSearch.php for an example of how this is done.

meh wrote:

I want to change the default search - not add a new one. As far as I can tell, this can only
be done by modifying index.php.

river wrote:

the only thing you seem to be doing in the example in the initial comment is
replacing the Special:Search page with something else.

if this is not what you want to do, could you please clarify?

meh wrote:

Perhaps I don't understand the software well enough... but if I search using the main page's
keyword entry box, the search uses SpecialSearch.php. I don't want it to use that - I want it
to always use my specialsearch page. I don't want to overwrite SpecialSearch.php, either - I
want to minimally affect the scripts and only make changes to LocalSettings.

Sure, I could replace SpecialSearch with my own version of it - but I want to avoid
overwriting existing scripts.

river wrote:

the wiki page "Special:Search" is not inherently tied to the file
"includes/SpecialSearch.php", it just uses that by default. by including (as an
extension) your own page that provides an implementation of Special:Search, and
setting $wgDisableInternalSearch, you can replace Special:Search with anything you
want -- no need to overwrite any files.

this is how LuceneSearch works; it's an extension, does not modify the MediaWiki
code at all, but replaces the built-in MySQL search with its own (Lucene-based)
implementation.

meh wrote:

That does it - much appreciated!