Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-60759

Solr 7.x compatibility with Moodle search plugin

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Install a new site
      2. Enable global search.
      3. Set the following constants in your config.php:

        define('TEST_SEARCH_SOLR_HOSTNAME', 'localhost');
        define('TEST_SEARCH_SOLR_PORT', '8983');
        define('TEST_SEARCH_SOLR_INDEXNAME', 'unittest');
        

      4. Generate phpunit files for moodle components:

        php admin/tool/phpunit/cli/util.php --buildcomponentconfigs
        

      Test 1
      1. Using docker, install solr 7 and create an index for your site using the same index name:

        docker run --name solr7 -d -p 8983:8983 -t solr:7
        docker exec -it --user=solr solr7 bin/solr create_core -c YOURINDEXNAME
        docker exec -it --user=solr solr7 bin/solr create_core -c unittest
        

      2. Go to "admin/settings.php?section=searchsolr", set YOURINDEXNAME as 'Index name' and save changes
      3. Go to "admin/category.php?category=searchplugins".
      4. On 'Setup search engine', you should see "Error validating Solr schema: field itemid does not exist. Please follow this link to set up the required fields.".
      5. Click on "follow this link"
      6. The process should finish without issues and you should see "Yes" for "Setup search engine"
      7. Now click on 'Index data' link and press 'Reindex all site contents'
      8. Confirm that search is working in search/index.php (search for 'admin' and admin user will appear as a result)
      9. Search component unit tests should pass without any skipped test

        vendor/bin/phpunit -c search
        

      Test 2
      1. Stop your solr 7 server.

        docker stop solr7
        

      2. Using docker, install solr 6 and create an index for your site:

        docker run --name solr6 -d -p 8983:8983 -t solr:6
        docker exec -it --user=solr solr6 bin/solr create_core -c ANOTHERINDEXNAME
        docker exec -it --user=solr solr6 bin/solr create_core -c unittest
        

      3. Go to "admin/settings.php?section=searchsolr", set ANOTHERINDEXNAME as 'Index name'.
      4. Save the changes
        Note: At this point it is possible that you see a solr client error debugging message; this message appears because the index we configured in test 2 is not available anymore, do not worry about it
      5. Go to "admin/category.php?category=searchplugins"
      6. On 'Setup search engine', you should see "Error validating Solr schema: field itemid does not exist. Please follow this link to set up the required fields.".
      7. Click on "follow this link"
      8. The process should finish without issues and you should see "Yes" for "Setup search engine"
      9. Now click on 'Index data' link and press 'Reindex all site contents'
      10. Confirm that search is working in search/index.php (search for 'admin' and admin user will appear as a result)
      11. Search component unit tests should pass without any skipped test

        vendor/bin/phpunit -c search
        

      Show
      Install a new site Enable global search. Set the following constants in your config.php: define('TEST_SEARCH_SOLR_HOSTNAME', 'localhost'); define('TEST_SEARCH_SOLR_PORT', '8983'); define('TEST_SEARCH_SOLR_INDEXNAME', 'unittest'); Generate phpunit files for moodle components: php admin/tool/phpunit/cli/util.php --buildcomponentconfigs Test 1 Using docker, install solr 7 and create an index for your site using the same index name: docker run --name solr7 -d -p 8983:8983 -t solr:7 docker exec -it --user=solr solr7 bin/solr create_core -c YOURINDEXNAME docker exec -it --user=solr solr7 bin/solr create_core -c unittest Go to " admin/settings.php?section=searchsolr ", set YOURINDEXNAME as 'Index name' and save changes Go to " admin/category.php?category=searchplugins ". On ' Setup search engine ', you should see " Error validating Solr schema: field itemid does not exist. Please follow this link to set up the required fields. ". Click on " follow this link " The process should finish without issues and you should see "Yes" for " Setup search engine " Now click on 'Index data' link and press 'Reindex all site contents' Confirm that search is working in search/index.php (search for 'admin' and admin user will appear as a result) Search component unit tests should pass without any skipped test vendor/bin/phpunit -c search Test 2 Stop your solr 7 server. docker stop solr7 Using docker, install solr 6 and create an index for your site: docker run --name solr6 -d -p 8983:8983 -t solr:6 docker exec -it --user=solr solr6 bin/solr create_core -c ANOTHERINDEXNAME docker exec -it --user=solr solr6 bin/solr create_core -c unittest Go to " admin/settings.php?section=searchsolr ", set ANOTHERINDEXNAME as 'Index name'. Save the changes Note: At this point it is possible that you see a solr client error debugging message; this message appears because the index we configured in test 2 is not available anymore, do not worry about it Go to " admin/category.php?category=searchplugins " On ' Setup search engine ', you should see " Error validating Solr schema: field itemid does not exist. Please follow this link to set up the required fields. ". Click on " follow this link " The process should finish without issues and you should see "Yes" for " Setup search engine " Now click on 'Index data' link and press 'Reindex all site contents' Confirm that search is working in search/index.php (search for 'admin' and admin user will appear as a result) Search component unit tests should pass without any skipped test vendor/bin/phpunit -c search
    • Workaround:
      Hide

      Because php cannot detect SOLR version (not pecl version like 2.4), Moodle has to ask user about solr version is equal or greater than 7, so i added a checkbox at the plugin settings

      Show
      Because php cannot detect SOLR version (not pecl version like 2.4), Moodle has to ask user about solr version is equal or greater than 7, so i added a checkbox at the plugin settings
    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-60759_master

      Description

      https://lucene.apache.org/solr/guide/7_0/field-types-included-with-solr.html

      http://lucene.apache.org/solr/7_1_0/changes/Changes.html#v7.0.0.upgrading_from_solr_6.x

      Apache Solr at version 7.x moved some fields types (Trie*) as deprecated, for example:

      int, tdate

      .At the moment Moodle uses these types as based.

      So we need a solution to make Moodle compatible to Solr 7.x+

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                17/May/18