Búsqueda global
Moodle 5.3
| Existe documentación diferente para varias versiones de Moodle: Esta página es acerca de la Búsqueda global para Moodle 5.3 . Puede ver la documentación anterior para Moodle 3.1. |
¿Qué es búsqueda global?
- Búsqueda global le permite a Usted buscar en todas partes en el sitio Moodle al que Usted tenga acceso. Un estudiante puede buscar en sus cursos algunas notas (apuntes) de curso, por ejemplo; o un profesor puede buscar actividades relacionadas con algún asunto.
- La característica de Búsqueda global tiene que ser habilitada por el administrador en Características avanzadas y entonces, desde la página para Gestionar Búsqueda Global, debe seleccionarse el motor de búsqueda.
Cuando está habilitada la Búsqueda Global, una caja de búsqueda está entonces disponible junto al menú del usuario.

- También puede añadirse un Bloque de búsqueda global a páginas de curso.
¿Qué puedo buscar?
Usted puede buscar sus cursos, información de actividades y algunos contenidos de actividades tales como publicaciones en foros, capítulos de libros, entradas del glosario o páginas de Wikis colaborativos.
El contenido de un Bloque HTML puede ser buscado y, si el administrador configura la configuración de "Cursos buscables" a Buscar dentro de todos los cursos a los que el usuario puede acceder, entonces los cursos que sean visibles a usuarios pero en los cuales no estén inscritos (matriculados) también pueden ser buscados. (Estos cursos son cursos con acceso de invitados, o si el usuario tiene la capacidad de ver todos los cursos).
¿Cómo funciona?
- Haga clic en el ícono para buscar que está cerca del menú del usuario y escriba un término a buscar dentro de la caja que aparece, o escriba dentro de la caja en el Bloque de búsqueda global si estuviera habilitado.
- En la pantalla siguiente, Usted puede simplemente hacer clic en el botón de búsqueda para buscar en cualquier lado, o puede expandir el Filtro para buscar en áreas específicas:

- Usted verá entonces los resultados mostrados desde todas las áreas de Moodle a las que Usted tenga acceso:

Características específicas de Solr
Estas características solo están disponibles si utiliza Solr como motor de búsqueda.
Características de la consulta de búsqueda
Puede mejorar su búsqueda utilizando cualquiera de las siguientes funciones de consulta:
- Especificar el campo a ser buscado, anteponiendo a la consulta los prefijos 'title:', 'content:', 'name:' o 'intro:'; por ejemplo, 'title:news' devuelve resultados que contienen la palabra 'news' en el título.
- Operadores booleanos ('AND', 'OR', 'NOT') para combinar o excluir palabras clave.
- Caracteres reemplazables comodines ('*' o '?') para representar caracteres en la consulta de búsqueda.
- Búsquedas por proximidad ('~'); por ejemplo, mood~2 devuelve "moodle" (a 2 letras de distancia de "mood"), y Moodle Australia~3 devuelve resultados que contienen "Moodle HQ in Perth, Australia" (los términos consultados se encuentran a una distancia máxima de 3 palabras entre sí).
- Ponderación de términos ('^') para dar mayor relevancia a ciertas palabras o frases; por ejemplo, "Perth Australia"^5 "Australia" devolverá resultados en los que la frase "Perth Australia" se considera más relevante.
Indexación de contenidos del archivo
Solr tiene la habilidad para indexar (indizar) los contenidos de los archivos. como por ejemplo Recursos Archivo y anexos a las publicaciones en Foros.
Filtros extra
Usted también puede filtrar por ID del usuario y buscar por grupo.
Mejora de Búsqueda Global
¡Nueva característica
en Moodle 5.3 !
La búsqueda global simple ahora admite la búsqueda de palabras parciales mediante la coincidencia de prefijos. Los usuarios pueden obtener resultados sin necesidad de introducir la palabra completa exacta.
La coincidencia de prefijos significa que Moodle busca coincidencias a partir del inicio de la palabra; por tanto, buscar una parte del nombre de un curso o actividad puede arrojar más de un resultado. Por ejemplo, al introducir 'Veg' se obtendrán coincidencias con 'Veg' y 'Vegetariano', ya que ambas empiezan por esas letras. No se buscan coincidencias en otras partes de la palabra; así, 'our' no coincidirá con 'resources'.
Si los usuarios realizan una búsqueda con varias palabras, se buscarán todas ellas (aplicando la lógica AND) para mostrar un resultado.
Por ejemplo, la búsqueda 'Veg Ing' coincide con 'Vegetarian Cooking: Ingredients and Techniques', ya que contiene una palabra que empieza por 'Veg' y otra que empieza por 'Ing'. No coincide con un curso llamado simplemente 'Vegetarian Cooking' ni con 'Baking Ingredients', puesto que a cada uno le falta uno de los dos términos.

¿Cómo se configura?
El núcleo de Moodle estándar incluye dos motores de búsqueda: la Búsqueda Global simple y Solr. Consulte la documentación para desarrolladores sobre plugins de motores de búsqueda si desea crear el suyo propio.
Configuración de la búsqueda simple
La búsqueda global simple ofrece funciones de búsqueda global sin necesidad de instalar un motor de búsqueda externo.
Configurar Solr
- Se recomienda utilizar la versión más reciente disponible de Solr 5.
- Moodle es compatible con el servidor Solr a partir de la versión 4.0; sin embargo, el script de configuración del esquema de Solr que se incluye con Moodle solo puede utilizarse con Solr 5. Se recomienda utilizar la versión más reciente disponible de Solr 5; lo mismo se aplicará a Solr 6 una vez que se publique.
Configuración general
Nota: Urgente de Traducir. ¡ Anímese a traducir esta muy importante página !. ( y otras páginas muy importantes que urge traducir)
- Set the feature up in Site administration > Plugins > Search > Manage global search by selecting Solr as the search engine and ticking search area checkboxes as required
- In Site administration > Plugins > Search > Solr, set Host name to localhost, Port to 8983 and Index name to 'moodle' (the name of the index in Solr)
- If you are using Solr with SSL encryption and basic authentication (see below if you want to use client certificates instead), you will need to configure this.This is important if solr is not installed in the web server server.
- Go to Site administration > Plugins > Search > Solr
- Set Secure mode to Yes
- Set port number if required (sometimes SSL installations use port 443).
- Type in the username and password.
- If you are using Solr with SSL encryption via client certificates, you will need to configure Moodle as such. This is important if solr is not installed in the web server server.
- You will need a separate key file and cacert file, both in pem format, located on your server Moodle, and readable by the PHP process.
- Go to Site administration > Plugins > Search > Solr
- Set Secure mode to Yes
- SSL certificate to /path/to/certs/solr-ssl.cacert.pem
- SSL key to /path/to/certs/solr-ssl.key.pem
- SSL key Password to The password used to lock the SSL Key
- SSL CA certificates name to /path/to/certs/solr-ssl.cacert.pem
- You now need to populate the created Solr index with your site's data. You can do it via the web interface by going to Site administration > Reports > Global search info or from the CLI by running the search/cli/indexer.php script. The CLI script is the recommended option for big sites.
# sudo -u www-run php search/cli/indexer.php --force - Enable Global search in Site administration > Advanced features
Indexado (Indizado) de archivos
Solr has the ability to index the contents of files, such as File resources and attachments to Forum posts. This uses the Tika engine which comes bundled with Solr. To enable this feature:
- In Site administration > Plugins > Search > Solr enable the checkbox Enable file indexing
- Set Maximum file size to index (kB) to some value - the default is 2097152 (2GB)
- Files larger than this limit will not be sent for Solr for indexing, but the file name will still be indexed.
Nuevo en Moodle 3.4: File indexing now works retroactively -i.e., if you set up Global search without file indexing enabled and a later date you enable file indexing, files associated with existing objects will be included.
Cómo instalar Solr
You need PHP Solr extension installed. You can download the official latest versions from PECL: Package: solr. The minimum required version is PECL Solr 2.1 for PHP 5 branch and PECL Solr 2.4 for PHP 7 branch.
Basic installation steps (using Apache web server):
Linux (Debian/Ubuntu)
Using APT:
sudo apt install php-solr sudo service apache2 restart
If you can't install the SOLR PHP module via APT, try the following:
With PHP5.x
sudo apt-get install libpcre3-dev libxml2-dev libcurl4-openssl-dev sudo apt-get install php5-dev sudo apt-get install php-pear sudo pecl install solr sudo sh -c "echo 'extension=solr.so' > /etc/php5/apache2/conf.d/solr.ini" sudo sh -c "echo 'extension=solr.so' > /etc/php5/cli/conf.d/solr.ini" sudo service apache2 restart
With PHP 7
sudo apt-get install libpcre3-dev libxml2-dev libcurl4-openssl-dev sudo apt-get install php7.0-dev sudo apt-get install php-pear sudo pecl install solr sudo sh -c "echo 'extension=solr.so' > /etc/php/7.0/apache2/conf.d/solr.ini" sudo sh -c "echo 'extension=solr.so' > /etc/php/7.0/cli/conf.d/solr.ini" sudo service apache2 restart
Linux (Redhat/Centos 6 & 7)
Uso de paquetes incluidos en php5
yum install php-pecl-solr2 service httpd restart
Uso de paquetes de terceros de php7 (webtactic)
yum install libxml2-devel pcre-devel libcurl-devel php70w-devel php70w-pear pecl install solr echo "extension=solr.so" > /etc/php.d/solr.ini service httpd restart
Linux (Amazon Linux 1)
AWS AMIs do not include the solr extension, but you are still able to compile the extension from source using pecl.
NOTE: this method will only build the solr extension for a single version of PHP (php7.3 in this example).
sudo yum -y groupinstall "Development Tools" sudo yum -y install php-pear php73-devel curl-devel libxml2-devel sudo pecl channel-update pecl.php.net # Locate /usr/share/pear/Archive/Tar.php # Line 639 # Change # $v_att_list = & func_get_args(); # to # $v_att_list = func_get_args(); # Choose desired php version as default sudo alternatives --config php # Set specific temp directory sudo mkdir -pv /build/tmp sudo pear config-set temp_dir /build/tmp sudo touch /etc/php-7.3.d/solr.ini sudo pear config-set php_ini /etc/php-7.3.d/solr.ini sudo pecl install solr-stable
OSX usando macports
sudo port install apache-solr4 sudo port install php54-solr
OSX usando homebrew
brew install homebrew/php/php56-solr
Windows
- Check your PHP version (see Site admin > Server > PHP Info) for PHP version, compiler (e.g. VC15), architecture (e.g. x64), and thread safety.
- Get the matching PHP extension DLL from PECL (or this page if not available on PECL).
- Add the DLL to you php\ext folder.
- Add the directive "extension=php_solr.dll" to your php.ini file.
- Restart your web server.
- Install the Java Runtime Environment
- Download Solr from the Solr Downloads page, e.g. solr-5.5.5.zip.
- Extract to an accessible place, e.g.: c:\solr-5.5.5
- From command line (as admin), in C:\solr-5.5.5, run...
- bin\solr start
- bin\solr status
- bin\solr create -c moodle
- bin\solr stop -all
- (As admin) Edit C:\solr-5.5.5\server\solr\moodle\conf\solrconfig.xml and change line...
<maxBooleanClauses>1024</maxBooleanClauses>
...to...
<maxBooleanClauses>524288</maxBooleanClauses>
- Create Scheduled task to start Solr
- General
- Run whether user is logged on or not
- Run at highest privileges
- Configure for Windows Server 2016
- Triggers
- Run daily (start any time)
- Repeat every hour, indefinitely
- Actions
- Start program
- Script: C:\solr-5.5.5\bin\solr.cmd
- Add arguments: start -m 2g
- Conditions
- Uncheck: Start the task only when the computer is on AC power
- Settings
- Uncheck: Stop the task if it runs longer than: ...
- If the task is already running, then the following rule applies: Do not start a new instance
- General
- Run the scheduled task manually (for now)
- At the command line, in c:\solr-5.5.5, run bin\solr status to check it is running
- Configure the Solr server in Moodle as below.
- Visit Site admin > Plugins > Search > Manage global search. It may prompt you to set up the search schema.
- Run the scheduled task to build the search index from the command line. It may initially need to run a few times as it will time out after 10min and you may have a lot of files.
php admin\tool\task\cli\schedule_task.php --execute=\core\task\search_index_task
- Keep an eye on the amount of memory used with solr status and the Task Manager (see the Java process).
El servidor Solr
Note that for medium/large sites you may need to increase maxBooleanClauses setting.
Please note that there is a security issue that affects some Solr versions. The patched versions are 5.5.5, 6.6.2, 7.1, 7.2 and all new versions are patched. If your Solr server version is lower but you can't upgrade to one of the patched versions it is recommended to disable the XML Query Parser.
The following example snippet (feel free to copy & paste into a .sh script with execution permissions) will download Solr 5.5.5 (replace it with latest 5.x) in the current directory, start the solr server and create an index in it named moodle to add moodle data to it. If wget gives an error, check http://www-us.apache.org/dist/lucene/solr and update SOLRVERSION
#!/bin/bash
set -e
SOLRVERSION=8.11.4
SOLRNAME=solr-$SOLRVERSION
SOLRTAR=$SOLRNAME'.tgz'
INDEXNAME=moodle
if [ -d $SOLRNAME ]; then
echo "Error: Directory $SOLRNAME already exists, remove it before starting the setup again."
exit 1
fi
if [ ! -f $SOLRTAR ]; then
wget http://www.apache.org/dist/lucene/solr/$SOLRVERSION/$SOLRTAR
fi
tar -xvzf $SOLRTAR
cd $SOLRNAME
bin/solr start
bin/solr create -c $INDEXNAME
# After setting it up and creating the index use:
# - "/yourdirectory/solrdir/bin/solr start" from CLI to start the server
# - "/yourdirectory/solrdir/bin/solr stop" from CLI to stop the server.
Configuración del esquema en Solr 5/6
Moodle will use Solr's managed schema interface to install the required fields. You will be directed on what to do from the Manage global search page.
For very large or busy sites, it is recommended that you manually remove the _text_ field, and associated copy directive from, the default Solr schema. This field is not used by Moodle, and will significantly slow indexing, and increase the size of the resulting Solr core.
Configuración del esquema en Solr 4
You cannot use the schema setup script when using a Solr 4 server. If you really want to use the Solr 4x branch, here are the field types descriptions:
Extracted from search/classes/document.php
| Field name | Field type | Stored | Indexed | Query field |
|---|---|---|---|---|
| id | org.apache.solr.schema.StrField | true | false | false |
| itemid | org.apache.solr.schema.TrieIntField | true | true | false |
| title | org.apache.solr.schema.TextField | true | true | true |
| content | org.apache.solr.schema.TextField | true | true | true |
| contextid | org.apache.solr.schema.TrieIntField | true | true | false |
| areaid | org.apache.solr.schema.StrField | true | true | false |
| type | org.apache.solr.schema.TrieIntField | true | true | false |
| courseid | org.apache.solr.schema.TrieIntField | true | true | false |
| owneruserid | org.apache.solr.schema.TrieIntField | true | true | false |
| modified | org.apache.solr.schema.TrieDateField | true | true | false |
| userid | org.apache.solr.schema.TrieIntField | true | true | false |
| description1 | org.apache.solr.schema.TextField | true | true | true |
| description2 | org.apache.solr.schema.TextField | true | true | true |
| solr_filegroupingid | org.apache.solr.schema.StrField | true | true | false |
| solr_fileid | org.apache.solr.schema.StrField | true | true | false |
| solr_filecontenthash | org.apache.solr.schema.StrField | true | true | false |
| solr_fileindexstatus | org.apache.solr.schema.TrieIntField | true | true | false |
| solr_filecontent | org.apache.solr.schema.TextField | false | true | true |
Consideraciones acerca de memoria e indexación de archivos
For large sites, and particularly if you are using the File indexing feature, it's a good idea to give Solr plenty of memory, e.g. aound 10-20GB. To start Solr with more than its default 512MB of RAM, use the -m option:
solr start -m 12g
See the documents for your version of Solr on how to increases memory when Solr is started automatically.
Error 'Too many boolean clauses'
Because of the way Moodle handles permissions for searches, if you have non-admin users with access to a large number of activities (>1000), they may an error similar to the following:
The query you provided could not be parsed by the search engine: org.apache.solr.search.SyntaxError: Cannot parse ... too many boolean clauses
To correct this, you need to increase the maxBooleanClauses setting in your Solr core. The setting is located in corename/conf/solrconfig.xml.
This important note is included in the config file:
** WARNING ** This option actually modifies a global Lucene property that will affect all SolrCores. If multiple solrconfig.xml files disagree on this property, the value at any given moment will be based on the last SolrCore to be initialized.
This means that for consistent behavior you should update this value for all cores in the Solr server.
Comandos para instalar Servidor Solr Server en Centos 7
First of all install java (openjdk)
yum install java-1.8.0-openjdk
Add user for solr
adduser solr
Download solr server, find latest here : http://lucene.apache.org/solr/mirrors-solr-latest-redir.html, from the list there download latest solr-[version].tgz
Here is the list of needed commands (note that latest solr is suggested, change command to appropriate version)
cd /opt wget http://www-eu.apache.org/dist/lucene/solr/6.6.0/solr-6.6.0.tgz tar zxvf solr-6.6.0.tgz cp solr-6.6.0/bin/install_solr_service.sh . rm -rf solr-6.6.0 ./install_solr_service.sh solr-6.6.0.tgz chkconfig solr on
Create the index
su - solr -c "/opt/solr/bin/solr create_core -c moodle"
Then go to your Moodle and set index name as created (moodle)
Vea también
Forum discussions:
MySQL Database Connection error with Simple Search: This SQL query should solve the issue
ALTER TABLE mdl_search_simpledb_index ADD FULLTEXT(title, content, description1, description2)
A quick introduction to Moodle global search, followed by a description of the new features and fixes in Moodle 3.4 (and some of those in Moodle 3.5).