Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 39 and 401]

Solr schema manipulation manager.

Copyright: 2015 David Monllao {@link http://www.davidmonllao.com}
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 349 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: schema  - X-Ref

Schema class to interact with Solr schema.

At the moment it only implements create which should be enough for a basic
moodle configuration in Solr.

__construct(engine $engine = null)   X-Ref
Constructor.

param: engine $engine Optional engine parameter, if not specified then one will be created
return: void

can_setup_server()   X-Ref
Can setup be executed against the configured server.

return: true|string True or error message.

setup($checkexisting = true)   X-Ref
Setup solr stuff required by moodle.

param: bool $checkexisting Whether to check if the fields already exist or not
return: bool

validate_setup()   X-Ref
Checks the schema is properly set up.

return: void

check_index()   X-Ref
Checks if the index is ready, triggers an exception otherwise.

return: void

add_fields($fields, $checkexisting = true)   X-Ref
Adds the provided fields to Solr schema.

Intentionally separated from create(), it can be called to add extra fields.
fields separately.

param: array $fields \core_search\document::$requiredfields format
param: bool $checkexisting Whether to check if the fields already exist or not
return: bool

validate_fields(&$fields, $requireexisting = false)   X-Ref
Checks if the schema existing fields are properly set, triggers an exception otherwise.

param: array $fields
param: bool $requireexisting Require the fields to exist, otherwise exception.
return: void

validate_add_field_result($result)   X-Ref
Checks that the field results do not contain errors.

param: string $results curl response body
return: void

doc_field_to_solr_field($datatype)   X-Ref
Returns the solr field type from the document field type string.

param: string $datatype
return: string