Commit graph

137 commits

Author SHA1 Message Date
Paladox
54c56da85a Fix php code style
Preparation change for updating mediawiki code sniffer to 0.8.0

Change-Id: Ib0b3fe4afea9096ffa3a1347b4f7e07d3398b0b2
2017-05-05 12:03:54 +00:00
Stanislav Malyshev
1e412aabdf Add deleted archive titles search
Allows search engine to suggest deleted titles for undelete search.
Note that the titles are still verified against the archive table,
to ensure search engine is not out-of-date.

Bug: T109561
Change-Id: Id6099fe9fbf18481068a6f0a329bbde0d218135f
2017-04-05 12:02:35 -07:00
jenkins-bot
0a2297c406 Merge "Fixes for more robust dealing with content handlers." 2017-01-30 16:06:25 +00:00
David Causse
cc61a14751 Allow SearchEngine users to access features data
Useful in case the client wants to re-evaluate what was set
here, or if the SearchEngine implementation wants to expose
some of its states.
In our case it allows CirrusSearch to inform SpecialSearch
that we prefer to display search results with a new experimental
layout.

Bug: T156299
Change-Id: I7f661c852ef70ea7bc9ae2959f7d6e48776a9877
2017-01-27 15:12:10 +01:00
Stanislav Malyshev
60ffe51c79 Fixes for more robust dealing with content handlers.
Change-Id: I12a02da005f4b2bceaa850bd1f41a90ac4e1754a
2017-01-26 12:20:07 -08:00
Max Semenik
d4f3e554d7 Decrease the number of 'function says it should return something' errors
Change-Id: Ib5115fe5bbaa67d8a6e54cc3ba1ba7020e239e11
2016-12-15 16:05:52 -08:00
dcausse
bd7df68603 Do not run exact db match if offset is > 0
When scrolling results on prefix search api the exact Title
match is always at pos 0 even if we want to scroll the results
by setting offset to > 0.

Change-Id: Ib02c9d3e479d739e6fe79014d962db50b6fd9de8
2016-09-27 15:28:14 +02:00
jenkins-bot
82dcfbe20e Merge "Pass User to SearchEngine::getProfiles" 2016-09-20 20:30:36 +00:00
dcausse
16e2491a73 Pass User to SearchEngine::getProfiles
Useful for search engines that allow users to customize search profiles.

Depends-On: Icd577c8ebc6e162befe30bde4fe276e633d2e434
Change-Id: I471cd090730d2a25cb70d622ec3bebbe9583118c
2016-09-20 20:22:23 +00:00
dcausse
8b890bbe1b Extract replacePrefixes into a static method
Useful for some search engines that have a keyword that wants
to reuse this logic without building a new SearchEngine object.

Change-Id: Iee5bfd1da70b8339a98555ba062bd33b21f0b761
2016-09-19 16:54:06 +02:00
Stanislav Malyshev
7e18cfc3b5 Infrastructure for augmenting search results
Bug: T117493
Change-Id: Ia5413a7846cc961026a2dc3542b619493bc76a23
2016-09-15 15:44:03 -07:00
Stanislav Malyshev
add1ebe2ab Make content handlers assemble content for search
Bug: T89733
Change-Id: Ie45de496ecc826211d98eea3a410c7639b4be0a4
2016-07-26 13:08:45 -07:00
Stanislav Malyshev
86b55ad03c Create API to allow content handlers to handle structured data definitions
Change-Id: Ia1738803c42f6114575587c1c838fec62b6f54aa
Bug: T89733
2016-07-06 13:41:20 -07:00
dcausse
31680aaddc Expose SearchEngine specific profiles
This patch introduces a way for SearchEngine implementations to expose
specific search profiles useful to fine-tune the various behaviors related to
search.

A SearchEngine can expose a list of profiles by overriding
SearchEngine::getProfiles( $profileType ), profileType stands for the type of
profile being customized. Two types are added in this patch:
- completion: exposed by ApiQueryPrefixSearch and ApiOpenSearch to control
  the behavior of the algorithm behind "search as you type" suggestions.
- fulltext query independent profiles: exposed by ApiQuerySearch to customize
  query indpendent ranking profiles (e.g. boost by templates/incoming
  links/popularity/...)

This patch allows api consumers that might have been confused by fuzzy
suggestions to switch to stricter profiles and to officialize the behavior
behind the hidden param cirrusUseCompletionSuggester. Or to control the
fulltext ranking behaviors like cirrusBoostLinks=(yes|no).

The list of profiles can be discovered by using ApiSandbox/ApiHelp and is totally
controlled by search engine implementations.

Bug: T132477
Change-Id: I66be724d8975976c98c91badbf421f237e014f89
2016-05-30 20:43:53 +02:00
dcausse
257c023666 Fix Undefined variable: namespaces in includes/search/SearchEngineConfig.php on line 109
Bug: T134305
Change-Id: I220886e12a6d083ac34a8a75bc77871e89dbf747
2016-05-03 21:41:15 +02:00
Ricordisamoa
e64035522d Fix and standardize Doxygen tags
* Use "@param datatype $paramname description" format

* String → string, Integer → int etc.

* @return $string → @return string

Change-Id: I860d222382cb4c5699d313b0600bd22503c8c385
2016-04-30 12:10:17 +02:00
Stanislav Malyshev
82c8c00ce2 Move wgContLang from config to injectable
Change-Id: Iffdc39f2de7d38ee9ef882bb796e8969e95e75c6
2016-04-27 11:55:17 -07:00
Stanislav Malyshev
34b02d87ac Convert SearchEngine to service containers
Change-Id: Icef1ecbed3d831557e0256fdfa53743b194007cc
2016-04-25 16:25:17 -07:00
dcausse
4c2f0e3940 completionSearch: try an exact match even if the backend returns no result
Unfortunately some backends (like Cirrus) are not able to do proper crossnamespace
lookup. If the backend returns no result we should still try an exact title match.

Bug:T129575
Change-Id: Ic08ec0aac0fd8a289f21753d74ae62ba509de841
2016-03-11 09:40:40 +01:00
aude
3a5931c3e5 Fix comment in SearchEngine.php
Change-Id: Ib00b42d2210be5bc1125fa7ba74c27a5d7fbf36c
2016-03-01 10:48:55 +01:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Stanislav Malyshev
027972a20f Include completion search into SearchEngine
By default it still uses PrefixSearch and supports PrefixSearchBackend
but it can be deprecated and phased out and SearchEngine extensions used
instead.

New APIs:
- SearchEngine
	public function defaultPrefixSearch( $search );
	public function completionSearch( $search );
	public function completionSearchWithVariants( $search );

Search engines should override:
protected function completionSearchBackend( $search );

Bug: T121430
Change-Id: Ie78649591dff94d21b72fad8e4e5eab010a461df
2016-02-03 23:41:49 +00:00
nomoa
33e5c11e85 De-duplicate near match query terms when generating variants
zhwiki generates 9 variants: we should not run these queries if the term is unchanged.

Change-Id: If23d19761dea33bf4bdcf6495becc8e983915fde
2016-01-11 17:33:00 -08:00
Erik Bernhardson
28abb2620a Document namespaces member as nullable
This variable is set to null in the replacePrefixes method, document
it as such to prevent errors in consuming code.

Bug: T98082
Change-Id: I78880ffe590ed7193b8482c0ae41c8c69e495878
2015-05-05 11:11:32 -07:00
Nik Everett
74b1c0d256 Add a sort parameter to SearchEngine
SearchEngine grows a method to list valid sort orders one to set the
sort for the next search, and one to read it.  The default implemenation
only supports 'relevance' and the documenation strongly urges that all
other implemenations leave that as the default.  Other implementations
can support other orders. Cirrus already supports title_asc and title_desc.

Change-Id: Ie946150c6796139201221dfa6f7750c210e97166
2015-01-07 13:41:18 -08:00
Aaron Schulz
e369f66d00 Replace wfRunHooks calls with direct Hooks::run calls
* This avoids the overhead of an extra function call

Change-Id: I8ee996f237fd111873ab51965bded3d91e61e4dd
2014-12-10 12:26:59 -08:00
Brad Jorsch
28e37f55c9 Merge OpenSearchXml extension into core
There's really no reason for the extension to exist separately from
core, and merging it reduces the risks of bitrot in both the extension
(lots of deprecated functions there) and core (missing integration with
PageImages and TextExtracts, for example).

Change-Id: Ie0ab90902ede9499879402290006466efba479e9
2014-11-26 21:07:22 -08:00
umherirrender
c2de24efcd Add missing @param to function docs
Change-Id: Ib7ac94d05a04490f25dfd40b46b27973cbab582c
2014-08-14 19:38:57 +00:00
jenkins-bot
a30854859e Merge "Remove SearchEngineReplacePrefixesComplete hook" 2014-06-24 07:20:18 +00:00
Chad Horohoe
da0070e9d1 Remove SearchEngineReplacePrefixesComplete hook
This hook is poorly thought out. The only extension that uses it
can't possibly think it works how they're expecting.

Change-Id: I853a01afc8e922f22e949321a2f2343d264632a6
2014-06-23 08:48:45 -07:00
Chad Horohoe
cd9dc7ef3f Database search fixes:
- Move filter() function and make it protected, nothing uses it
  outside database-backed searching
- Use per-backend legal search characters rather than assuming the
  static implementation is right

Change-Id: Ic2b830b56137b2dfe68b9b9c3de012151e716952
2014-06-20 13:43:36 -07:00
Chad Horohoe
9643a0a92d Remove SearchResultTooMany
Only worked for Postgres, and only worked halfway at that. Result
sets could be false for many reasons. No results, bad query, database
went to Mars. We shouldn't assume they're always "too many results."

Leave it up to the normal query error logging and move on.

Change-Id: Ieddd163e440ae54b152541d727c1afdbc4ab4fbd
2014-06-20 10:36:47 -07:00
Nemo bis
5dc4dc099d Save advanced search namespace prefs on Special:Search itself
* Checkbox on own row below power search checkboxes per MatmaRex;
  avoiding a mw-search-ns* id leaves it untouched by All/None JS.
* The option searcheverything is removed: a "shortcut" which is no
  longer necessary now that options can be (un)selected at once
  with All/None buttons on search page itself.
* Require a token for saving: no accidental preferences changes.
* Keep the searchoptions/advancedsearchoptions prefs section in case
  something is using it (no known extension does though); options
  are converted to "api" type so it's empty and hidden by default.
* Add minimal documentation for saveSettings() and friends
  (@todo since 155ddf6de, 2009!).

Bug: 52817
Change-Id: I514cee835988600cc013658049e88a10b670e64a
2014-05-30 14:33:47 -07:00
Chad Horohoe
1cb1ac6278 Remove "Help/Project" profile from Special:Search
The vast majority of wikis have an empty help namespace and
searching project pages is mostly an advanced search feature.

Cluttering the UI with an extra tab that's (most likely) rarely
clicked isn't helping anyone.

Change-Id: I0c448bcee877e027ff95c96812aac86d89d4eb32
2014-05-12 11:10:18 -07:00
Siebrand Mazeland
b1aa60af25 Pass phpcs-strict on includes/search/
Change-Id: Ia38af607b1f2a8e49f60f1a659a14b801e7dcda0
2014-05-09 22:32:17 +02:00
umherirrender
dcf6955e5c Fixed some @params documentation (includes/*)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: Ifbb1da2a6278b0bde2a6f6ce2e7bd383ee3fb28a
2014-04-20 23:33:05 +02:00
umherirrender
edc924869f Changed some comments from /// to /** @var */
Change-Id: I55b30099e4464c272c35bcabbddbb0b1364a5d65
2014-04-07 05:01:19 +00:00
Chad Horohoe
7e8c48ac3d Remove "include redirects" option from search
Always include redirects. Search results are worse without them
and MWSearch has never respected this option anyway.

Change-Id: I0ebe321a3b14e7960aa98e3225dc5a19ba916e7d
2014-03-26 09:28:26 -07:00
Chad Horohoe
7fc1a5b137 Break up SearchEngine.php into a couple of other files
Change-Id: I753eec1d0cf78f2ea08897c7fd3b83f2c88be18d
2014-03-19 20:14:17 +00:00
umherirrender
047c86f26e Fix spacing between two functions
Added and removed some new lines to have one new line between two
functions

Change-Id: I1ccfbd575dd26b160396ef3d3e2e079f5cdbe196
2014-03-15 20:57:23 +00:00
Chad Horohoe
3476fcc5da Remove unused $terms parameter
None of the following extensions use these parameters:
- CirrusSearch
- MWSearch
- SolrSearch
- SphinxSearch

Change-Id: I9686ca0849f35a3a09bd9996e4c6eac4334a342a
2014-03-04 13:26:12 -08:00
Chad Horohoe
653b7d63bc Support interwiki searches in API
Adds new SearchResult methods for getting namespace text

Bug: 60975
Change-Id: I381c8681cabfa9ff7a73cbe0286ed32d267a5990
2014-02-25 13:54:23 -08:00
Nik Everett
4e3e752a9e Don't offer create link for searches with syntax
Rather, create a hook that search implementations can override to specify
that the search contained advanced syntax and core will read it in
Special:Search and only offer the link if it is false.  It'll default
false.

Change-Id: Ic4ce6361d0e602ed9a812dfbbd15ce11a762f5f8
2014-02-04 13:28:19 -05:00
Nik Everett
f8dbaac443 Handle space in namespace prefixed searches
MWSearch handles namespace prefixed searches containing spaces so core
should as well.

Bug: 60489
Change-Id: I7e602d005a8b2786942b76b7185882e5107942c4
2014-02-04 10:57:19 -05:00
Chad Horohoe
ed2f768c62 Remove unused acceptListRedirects()
Change-Id: I411f6f9934917b424591287f5bebbb8183952f32
2014-01-30 11:08:29 -08:00
Chad Horohoe
791a384979 Don't override limits and offsets in SearchEngine::create()
The class default is 10/0, it doesn't make sense to set that
as 0/0 here. Nor does it make sense to really override it
here at all, as class defaults should take precedent unless
explicitly overriden by callers.

Bug: 60475
Change-Id: I4a48fd3c55908b52c8b0ab081d856874d16b876e
2014-01-27 08:55:40 -08:00
jenkins-bot
bb70f87a13 Merge "Begin abstracting more of the database-specific search backend out" 2014-01-23 23:39:34 +00:00
Chad Horohoe
110eb02f3a Begin abstracting more of the database-specific search backend out
There's a lot in the base search implementations that is specific
to the database backed search. This starts moving some of that out
into a shared base class for those.

For starters, let's not grab a connection to the slave DB for
every single search for backends unless they need it.

Change-Id: Ib66696841eea901e04b21dd309784af889a45ab1
2014-01-21 17:53:16 -08:00
Chad Horohoe
05cbfe0ad4 Allow SearchResults to specify that they matched file content
Change-Id: I214406250d10b971dcca025da508272d9805567b
2014-01-17 10:50:08 -05:00
Chad Horohoe
d109ff79e1 Two fixups to SearchResult
- Make variables protected. Only class that uses these is LuceneResult
  and it's fine
- Don't bother constructing a new file object if we've already got
  one in memory (we likely do)

Change-Id: I7973aff1e96297a2fea70392b765c93a8c884d52
2014-01-14 16:21:53 -08:00