111 Commits

Author SHA1 Message Date
sam marshall
7ba2a20166 MDL-66326 Global search: Delete from index when courses are deleted
Adds new API support within search engines for optional methods to
delete data for courses and contexts, and implements this for the
two core search plugins (simpledb and solr).

The new API is automatically called when courses or contexts are
deleted. When a whole course is deleted, it only sends the course
delete rather than sending 1,000 separate context deletions as
each activity/block is deleted.
2019-08-23 11:51:50 +01:00
Sagar Ghimire
36667548b5 MDL-60916 core_course: Replace course search with global search 2019-08-05 16:05:10 +10:00
sam marshall
ed73ff2b0e MDL-66132 Search: Behat tests should use simpledb, fix mock count
When searching using mock results (the 'global search expects the
query' step), the result count is not correctly set. As a result, the
page incorrectly reports that there are no results and doesn't
correctly show the first page of multi-page results.

Additionally, some of the core Behat tests can now be moved to use
real searching with the simpledb engine, rather than using mock
results at all. This gives better tests.

Unfortunately it was not possible to move all of the core Behat tests
and deprecate the mock step, because some of the tests are related to
the UI for 'special' features searching by user or group, neither of
which are supported by the simpledb engine.
2019-07-12 15:31:30 +01:00
Amaia Anabitarte
c5b2f2b306 MDL-59502 Global Search: deprecate add_documents 4 arg implementation
In MDL-59039 we introduced changes to add_documents and should return an extra $partial boolean.
We still supported implementations returning 4 elements since then,
but  this issue is about removing this 4 returned elements compatibility.
2019-06-20 18:58:17 +02:00
Eloy Lafuente (stronk7)
7c924d311d Merge branch 'MDL-64284-36_get_component_classes_cache' of https://github.com/tomdickman/moodle 2019-04-11 20:01:37 +02:00
Marina Glancy
beff3806d6 MDL-10965 courses: capability to browse course list 2019-04-10 12:35:28 +02:00
Tom Dickman
0d6a45d2fe MDL-64284 core: improved performance of component class searching
Added static caching of classes to reduce load times and reduce calls to `get_component_classes`
by altering to accept a null component value to search classmap only once.
2019-03-29 11:44:43 +11:00
Dmitrii Metelkin
2085e8603a MDL-62869 search: implement searching for all courses 2019-03-01 07:18:37 +11:00
Dmitrii Metelkin
e9074ee381 MDL-60913 search: add search area categories 2019-01-23 10:28:43 +11:00
Andrew Nicols
f89f6cf04e Merge branch 'MDL-62899-search-icons-master' of https://github.com/dmitriim/moodle 2018-08-08 13:17:34 +08:00
Dmitrii Metelkin
66f145efd1 MDL-62899 search: add document icons 2018-08-07 17:40:57 +10:00
Victor Deniz
10505522fc MDL-57977 search: GlobalSearch by alternate name fields
Enable support for searching all name fields in search
2018-07-23 10:10:05 +01:00
David Monllao
74fc7d3120 MDL-62217 search: Privacy providers 2018-05-09 10:56:02 +02:00
David Monllao
26b86f31e5 MDL-61028 search: Clear search engine users cache after tests 2018-04-24 15:48:40 +02:00
David Monllao
590c774d37 Merge branch 'MDL-62042-master' of https://github.com/sammarshallou/moodle 2018-04-23 16:07:37 +02:00
David Monllao
c5a8065258 Merge branch 'MDL-61028-master' of https://github.com/sammarshallou/moodle 2018-04-23 13:09:53 +02:00
sam marshall
a6cacdd266 MDL-61028 core_search: Allow filtering search by user (front-end)
Creates a new 'Users' field in the search filters form. This field
requires new JavaScript and, to implement this, a new AJAX-callable
web service to search for users by name, with detailed restrictions
based on the current user's access to view profiles.
2018-04-20 17:10:03 +01:00
sam marshall
222a97ce76 MDL-61028 core_search: Allow filtering search by user (back-end, Solr)
Adds support in the Solr engine for a new 'userids' parameter to
restrict search results to those created by a specific user or users.
2018-04-20 13:36:55 +01:00
sam marshall
ffa868a9e1 MDL-62042 core_search: Unicode non-characters cause indexing problems
Unicode characters such as U+FFEF can be entered into Moodle data and
cause indexing failures. This change strips them out of search fields.
2018-04-19 16:54:47 +01:00
David Monllao
8000eac408 MDL-61102 core_search: Restore search manager instance 2018-04-19 13:38:35 +02:00
David Monllao
0299444710 Merge branch 'MDL-61102-master' of https://github.com/sammarshallou/moodle 2018-04-19 10:37:30 +02:00
sam marshall
73fd56663b MDL-61102 core_search: Improve performance by reducing schema checks 2018-04-18 16:24:51 +01:00
David Monllao
82f0ddc7c7 MDL-60953 search: Update groups support method name 2018-04-16 11:45:18 +02:00
David Monllao
9dbb24fa7a Merge branch 'MDL-60953-master' of https://github.com/timhunt/moodle 2018-04-16 11:43:53 +02:00
sam marshall
a539e5605c MDL-61824 core_search: Deleting restored context caused error
When restoring content, this adds it to a queue for indexing. If the
restored content was then deleted before the indexing takes place,
this caused an exception in the scheduled task.

This change makes it continue safely past missing contexts.
2018-04-09 16:36:30 +01:00
sam marshall
3c49b0e6b6 MDL-60953 core_search: UI to search by group 2018-04-05 11:42:09 +01:00
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