85 Commits

Author SHA1 Message Date
sam marshall
fc440796e9 MDL-59434 core_search: Alternate result orders including by context
Implements a mechanism by which search engines can provide different
result orderings, and implements a 'by location' ordering within the
Solr search engine (available whenever the user starts their search
from within a course or activity).
2018-03-20 12:15:25 +00:00
sam marshall
4359ef18bb MDL-58885 core_search: Add group support
Adds group support to the core search API and the Solr search engine.
This allows for:

* User searching by group (in the API only, no interface yet)
* Automatically restrict search results by group (in some cases like
  separate-groups forums)
2018-02-16 16:57:00 +00:00
sam marshall
d20ec3606b MDL-60943 core_search: Improve exception for preg_replace errors 2018-01-04 17:27:46 +00:00
sam marshall
65da6840f8 MDL-60981 core_search: UI to gradually reindex a single area
Adds a new 'Gradual reindex' link to the search areas page for each
area. When clicked, this takes you to a confirm prompt, and then
adds each context from that search area to the indexing queue.

The search areas page now displays the 'Additional indexing queue'
(if it is non-empty). The table shows the first 10 items in the
queue, and it also indicates the total number in case there are
more. (I don't think people really need to see the entire
contents of it, so I didn't implement paging.)
2017-12-22 13:05:11 +00:00
sam marshall
8736fbc190 MDL-60981 core_search: New indexpriority field in search index queue
Adds indexpriority field to the database table which holds a queue of
indexing requests. This allows for potentially large area reindexes
to have a lower priority, so as not to halt the special indexes that
run after a course restore.
2017-12-22 13:05:10 +00:00
sam marshall
25564a784b MDL-60981 core_search: Add get_contexts_to_reindex API
This new API returns a list of contexts for each search area. This
allows the areas to be reindexed in a sensible order (roughly
speaking, newest first) and also allows this to be controlled by
each area.

An implementation in the forum module means that forums are ordered
by the date of the most recent discussion, so that active forums
will be reindexed early even if they were created a long time ago.
2017-12-22 13:02:37 +00:00
Damyon Wiese
97812f14c1 Merge branch 'MDL-60880-master' of https://github.com/sammarshallou/moodle 2017-12-06 19:53:37 +13:00
sam marshall
7f9fb2c846 MDL-60880 core_search: Allow search of specific context (front-end) 2017-12-05 17:42:40 +00:00
sam marshall
cfa00fc565 MDL-60880 core_search: Allow search of specific context (back-end)
Adds back-end support for restricting searches to specified context
ids (for example so it is possible to search only a specific forum).
2017-12-05 17:42:38 +00:00
sam marshall
1b8cf12a59 MDL-60857 core_search: Improve cron log progress information 2017-12-01 15:47:22 +00:00
Jake Dallimore
e105a752c0 Merge branch 'MDL-60707' of git://github.com/aolley/moodle 2017-11-13 13:26:00 +08:00
Adam Olley
7f83e99e5f MDL-60707 core_search: In tests, use faked time for indexing length
Without this change its possible that the unit tests will fail at any time.
Before this change the indexing time is measured by real-time, not fake time,
making all index timings 0.

This happens as PHP offers no guarantee around the sort-order of an array for
any given two members that equate as equal. It just happens to pass for the
current array of search areas in vanilla Moodle.
2017-11-09 10:49:53 +10:30
sam marshall
4b0facc984 MDL-60720 core_search: Indexing halts on failed get_document
The recordsets used for search indexing sometimes return results
which are invalid (e.g. cannot be found in database). When this
happens, the result in the iterator for the recordset will be
false. Due to a bug, the iterator used to stop when it encountered
a false value, which prevented indexing from getting past the
problematic record.

In addition, the iterator that skips future data resulted in the
current() function of its parent indicator being called twice per
entry, which meant that search indexing called get_document()
twice as many times.
2017-11-07 16:36:37 +00:00
sam marshall
82735dec4d MDL-60555 core_search: Change unit tests to use fake time
Using real time caused rare failures. I've changed it to use fake
measurement for the indexing timeouts, which were unit-tested.
2017-10-31 14:48:09 +00:00
Andrew Nicols
0049244893 MDL-60357 search: Ensure that the document is valid
We were previously testing tha the parent is valid, which it was, and
then fetching the current record, before fetching data from it.

However, the way in which the recordset walk works, the valid function
checks whether the _record_ itself is valid, whilst the current allows
for a callback to be applied.

In this instance, the data-entry was failing because the count of
indexfields was < 2. The recordset data itself was valid, but the view
was not, and as a result, the current() function returned false.

This false was not previously handled.

I've changed the logic so that we handle this case, and have removed a
double-negative in the process.
2017-10-13 09:41:59 +08:00
Andrew Nicols
e61ad18e70 Merge branch 'MDL-55356-master' of https://github.com/sammarshallou/moodle 2017-10-12 11:28:04 +08:00
sam marshall
74b7a42d0d MDL-55356 core_search: Make indexing task/CLI do context requests 2017-10-11 17:17:10 +01:00
sam marshall
4ba11aa907 MDL-55356 core_search: New manager API index_context
New function which uses the get_document_recordset function in
search areas to support full and partial indexing of a given
context.
2017-10-11 17:17:10 +01:00
sam marshall
427b756355 MDL-55356 core_search: New area API get_document_recordset
The search area API now includes a new function get_document_recordset
which should be implemented in preference to the older
get_recordset_by_timestamp. (It's also possible to implement both in
plugin search areas which need to work against older Moodle versions.)

Existing search areas without the new function will continue to work as
before (obviously without the new functionality).
2017-10-11 17:17:08 +01:00
sam marshall
eacb2bd11b MDL-55356 core_search: API to queue contexts for indexing
New API \core_search\manager::request_index($context, $areaid = '')
adds the given context to a list which is intended to be indexed
later by the scheduled task.
2017-10-11 17:17:07 +01:00
sam marshall
d761b3fb19 MDL-55356 core_search: API to check if indexing enabled
New function \core_search\manager::is_indexing_enabled(), analagous
to existing is_global_search_enabled().

This replaces existing duplicated code, ready for more use in
following commits.
2017-10-11 17:17:06 +01:00
sam marshall
0da8f62f3b MDL-55356 core_search: Make base_block handle empty restored blocks 2017-10-11 17:17:05 +01:00
sam marshall
2d2fcc1c9e MDL-60357 core_search: Future modified times cause serious problems 2017-10-06 13:38:32 +01:00
sam marshall
2d94d4ea7c MDL-59913 Global search: Allow search of non-enrolled courses 2017-09-29 16:30:37 +01:00
Eloy Lafuente (stronk7)
db7083c4c4 Merge branch 'MDL-60105_master' of git://github.com/dmonllao/moodle 2017-09-19 01:55:12 +02:00
Matt Clarkson
3043fe924d MDL-60105 search: Fix fatal error
If an indexed file has been modified or deleted the search index
will still reference the old file. Remove the file from search
results until the change has been indexed.
2017-09-13 13:51:30 +02:00
Eloy Lafuente (stronk7)
2e6112dd3f Merge branch 'MDL-59926-master' of https://github.com/sammarshallou/moodle 2017-09-12 00:27:49 +02:00
sam marshall
e36eefaeea MDL-59926 core_search: Allow Behat testing of results screens 2017-09-04 17:42:53 +01:00
Matt Porritt
4e921569d0 MDL-59459 Golbal Search: Increase file indexing coverage
Increase the scope of the files that are detected and
indexed by Moodle's Global Search. This includes intro
and content areas of search areas. The use case here is
in a description for an activity there is a file added
that contains more information about the activity.
It would an advantage to be able to search this content
as well. It would also allow search engine plugins to be
able to index non text files such as images.
2017-09-02 10:28:17 +10:00
sam marshall
e80e4778c5 MDL-58957 Global search: fix failing text compare in Oracle 2017-07-13 14:41:37 +01:00
Simey Lameze
a14907faa8 MDL-58957 core_block: fix link to site home 2017-07-13 11:10:36 +08:00
David Monllao
afabbd110e Merge branch 'MDL-59039-master' of https://github.com/sammarshallou/moodle 2017-07-11 21:49:03 +02:00
sam marshall
67d6479581 MDL-59039 Global search: Allow partial indexing (in scheduled task) 2017-07-11 16:41:33 +01:00
sam marshall
a96faa49a8 MDL-58957 Global search: Add block support to search manager 2017-06-30 13:10:12 +01:00
Matt Porritt
0a9a10f029 MDL-58654 Global search: Allow engines to support batch processing.
Allow Global Search 3rd party engines to be much faster by supporting batch processing.
Refactor the iterator loop for the documents to add to the search index into its own method.
Move this new method from the manger class to the base engine class.
The move to the base engine class will allow search engine plugins to override this and determine
how they implment it. It will not break the existing interface contract with existing plugins.

Finally, add an elasped time indication to the trace output.
2017-05-31 08:28:12 +10:00
David Monllao
b805d3f8ef MDL-56057 search: Fix incorrectly reported no enabled search areas
Also improved performance caching enabled search areas and
all search areas at the same time.
2016-10-12 08:30:23 +08:00
David Monllao
e71061a22b MDL-55191 search: Generate an search result viewed event 2016-09-15 09:36:49 +08:00
David Monllao
f3d38863fe MDL-55390 search: is_search_area unit tests
Added extra checking for search manager get_search_area.
2016-08-09 15:51:30 +08:00
Andrew Nicols
46c31069f3 MDL-55390 core_search: Correct variable name 2016-08-09 13:44:10 +08:00
Devang Gaur
396d6f0a6e MDL-55390 core_search: check if a search area is real 2016-08-05 01:12:21 +05:30
David Monllao
2a36babbc8 MDL-55357 search: Contents include UTF8 characters, adding u modifier 2016-07-29 14:36:17 +08:00
Dan Poltawski
773a11519d Merge branch 'MDL-55278_master' of https://github.com/dmonllao/moodle 2016-07-26 11:57:09 +01:00
David Monllao
379ca98642 MDL-55287 search: Check that an engine has been selected 2016-07-21 18:40:29 +02:00
David Monllao
0bd8383a8b MDL-55278 search: Updating references to area namespace 2016-07-21 18:38:18 +02:00
David Monllao
8fa1810cec MDL-55278 search: Get rid of core_search\area namespace 2016-07-21 18:38:18 +02:00
Dan Poltawski
b76edf3cfa Merge branch 'MDL-54926-master' of git://github.com/merrill-oakland/moodle 2016-07-11 16:54:40 +01:00
Dan Poltawski
64ec975e19 Merge branch 'MDL-55082-master' of git://github.com/merrill-oakland/moodle 2016-07-11 15:20:48 +01:00
David Monllao
6a4c2146f9 MDL-53222 search: Replace report_search by new searchareas admin page 2016-07-11 11:49:14 +02:00
Dan Poltawski
c3a95c2840 MDL-53222 admin: rejig listing of search areas 2016-07-11 11:38:41 +02:00
Andrew Nicols
91dc1e8795 Merge branch 'MDL-55053-master' of git://github.com/merrill-oakland/moodle 2016-07-04 14:04:23 +08:00