{"_id":"576b21a127d6252b000853c5","project":"56be3387be55991700c3ca0d","version":{"_id":"56be3388be55991700c3ca10","project":"56be3387be55991700c3ca0d","__v":8,"createdAt":"2016-02-12T19:33:28.313Z","releaseDate":"2016-02-12T19:33:28.313Z","categories":["56be3389be55991700c3ca11","57646709b0a8be1900fcd0d8","5764671c89da831700590782","57646d30c176520e00ea8fe5","5764715d4f867c0e002bc8e3","57698fa2e93bfd190028815c","576c2af16c24681700c902da","5787da96b008c91900aae865"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"category":{"_id":"57698fa2e93bfd190028815c","version":"56be3388be55991700c3ca10","project":"56be3387be55991700c3ca0d","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-06-21T19:04:02.961Z","from_sync":false,"order":1,"slug":"integrations","title":"Guides"},"user":"5633ec9b35355017003ca3f2","__v":8,"parentDoc":null,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-06-22T23:39:13.797Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"In this guide, we're going to cover the basics of setting up a Websolr index to be used with Drupal 7 and the ApacheSolr module. A few points to note before we get started:\n\n  * This example uses Drupal 7.22 and ApacheSolr version 7.x-1.3. Your versions may vary; as long as the major versions are the same, you can reliably use this guide.\n  * This guide is not meant to be an exhaustive tutorial on all of the things the ApacheSolr module can do. The goal here is to get you up and running quickly, then let you tune things as necessary.\n  * If you run into issues while following this guide, make sure to check the \"Troubleshooting\" section at the bottom and see if a solution is addressed there. \n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Getting started\"\n}\n[/block]\nFor the purposes of this tutorial, I set up a vanilla Drupal 7 install. I used the Devel module to generate 50 nodes of random content so we would have something to index later. After my dummy content was created, I uninstalled and removed this module. I also downloaded the [apachesolr](https://drupal.org/project/apachesolr) module and extracted it to `sites/all/modules/apachesolr` Other than that, I did not add or change any module settings along the way. Your situation is probably different, but it shouldn't matter at this point.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/40ca415-01_-_home.png\",\n        \"01 - home.png\",\n        1378,\n        874,\n        \"#3d85b4\"\n      ]\n    }\n  ]\n}\n[/block]\nMake sure you navigate to `admin/modules` and verify that the ApacheSolr module and its related modules have been activated:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/6aa274d-02_-_modules.png\",\n        \"02 - modules.png\",\n        1148,\n        311,\n        \"#e9eae3\"\n      ]\n    }\n  ]\n}\n[/block]\nGreat! That's all you need to get started. Next, we'll configure the Websolr index that will hold your documents.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting up the Websolr index\"\n}\n[/block]\nNext, you'll want to [add a new slice](https://websolr.com/slices/new) to your websolr account. Give your index a descriptive name, select the server group nearest to your application, then select \"Drupal ApacheSolr Search 7.x-1.1\". Don't worry if the minor versions are different between your system and this tutorial:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e0c6118-03_-_d7-apachesolr-create-index.png\",\n        \"03 - d7-apachesolr-create-index.png\",\n        651,\n        377,\n        \"#ddebea\"\n      ]\n    }\n  ]\n}\n[/block]\nWhen this form has been filled out, go ahead and click \"Create.\" Afterwards, you will be redirected to a page that shows the status of your index and will probably show a message about taking a few minutes to complete:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/353261d-04_-_d7-apachesolr-create-index-2.png\",\n        \"04 - d7-apachesolr-create-index-2.png\",\n        645,\n        325,\n        \"#dbeae9\"\n      ]\n    }\n  ]\n}\n[/block]\nThis is usually finished within a few minutes, so take a short break. When you come back, hit refresh to see the following:\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0010d87-05_-_d7-apachesolr-create-index-3.png\",\n        \"05 - d7-apachesolr-create-index-3.png\",\n        650,\n        328,\n        \"#dbeae9\"\n      ]\n    }\n  ]\n}\n[/block]\nIf you see a message that says your index looks ok, you're done. Occasionally provisioning errors will occur and you will see a message about taking a long time to provision your index. Try appending \"/refreshing\" to the page's URL and give it a minute or two. If that doesn't clear things up, you will need to open a [support ticket](http://help.websolr.com) and have the Support Team take a closer look.\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting up the ApacheSolr Module\"\n}\n[/block]\nOnce your websolr index is up and running, it's time to configure the ApacheSolr module. Navigate to `admin/config/search/apachesolr/settings` and you should see something like this:\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/9601209-06_-_d7-apachesolr-configure-apachesolr.png\",\n        \"06 - d7-apachesolr-configure-apachesolr.png\",\n        1194,\n        402,\n        \"#ebebe4\"\n      ]\n    }\n  ]\n}\n[/block]\nThis is the default setting that comes bundled with the module. Clicking on the \"Edit\" link will bring up the following form:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/3187ea4-07_-_d7-apachesolr-configure-apachesolr-2.png\",\n        \"07 - d7-apachesolr-configure-apachesolr-2.png\",\n        1192,\n        554,\n        \"#e8e3d9\"\n      ]\n    }\n  ]\n}\n[/block]\nYou will want the Solr server URL to point to the URL of the websolr index that you just created. Note that websolr communicates over the standard HTTP port 80, not 8080 or 8983 (standard ports for Tomcat and Jetty respectively). Consequently, you can leave out the port specification and your app will still be able to communicate with websolr. For example, my settings look like this:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/b81bb3e-08_-_d7-apachesolr-configure-apachesolr-3.png\",\n        \"08 - d7-apachesolr-configure-apachesolr-3.png\",\n        1189,\n        555,\n        \"#e9e4da\"\n      ]\n    }\n  ]\n}\n[/block]\nOnce you have your URL and a description set up, go ahead and click on \"Test connection\" to verify that everything is working. You should get a message that your site has contacted the Apache Solr server. If not, check your settings and try again. Once the connection has been verified, click on \"Save.\"\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0f1e383-09_-_d7-apachesolr-configure-apachesolr-4.png\",\n        \"09 - d7-apachesolr-configure-apachesolr-4.png\",\n        1179,\n        606,\n        \"#e6eae1\"\n      ]\n    }\n  ]\n}\n[/block]\nNext, click on the \"Default Index\" tab. You will see a few actions for indexing, reindexing and deleting the index. You will probably also see the message: \"Error: No data was returned from the server.\" This is NOT an error. It is due to how the ApacheSolr module verifies a connection to the Solr server. Essentially, it requests some administrative functions which are blocked for security reasons by websolr. This [KB article](http://help.websolr.com/kb/common-problems/drupal-apachesolr-module-401-authorization-required) has more information. Basically, don't worry about it:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/abc781b-10_-_d7-apachesolr-configure-apachesolr-5.png\",\n        \"10 - d7-apachesolr-configure-apachesolr-5.png\",\n        1194,\n        700,\n        \"#dadcd8\"\n      ]\n    }\n  ]\n}\n[/block]\nClick on the first option, \"Index queued content.\" This will index a maximum of 50 documents (by default). You could also index all documents at this time, but that may take a while depending on how many documents you have.If everything went smoothly, you should get a message like the one below. If you see any errors (except for the previously-mentioned one about no data being returned from the server), double-check that your settings are correct and that the apachesolr module can communicate with websolr:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/d42fd25-11_-_d7-apachesolr-configure-apachesolr-6.png\",\n        \"11 - d7-apachesolr-configure-apachesolr-6.png\",\n        1194,\n        698,\n        \"#193547\"\n      ]\n    }\n  ]\n}\n[/block]\nFinally, navigate to `admin/config/search/settings` and make sure that the ApacheSolr module is set to the default search module. You may also want to disable the other modules, especially if you don't need them:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/f1f1b0d-09a_-_d7-apachesolr-configure-apachesolr-1.png\",\n        \"09a - d7-apachesolr-configure-apachesolr-1.png\",\n        1152,\n        365,\n        \"#d4d1c9\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Checking on your index\"\n}\n[/block]\n\nAfter the apachesolr module has indicated a successful indexing of your documents, you can navigate to your websolr URL and append \"/select\" to it. For me, this was `http://ec2-west.websolr.com/solr/750f846502e/select` This will return the first set of documents in your index. If you don't see them right away after indexing, don't worry. For reasons of network performance and stability, all websolr indices have a 60 second commit time. This means your documents can take up to 60 seconds to show up in your index; if you don't see them right away, just wait a minute, then hit refresh:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/01be15c-12_-_d7-apachesolr-query-results.png\",\n        \"12 - d7-apachesolr-query-results.png\",\n        1359,\n        840,\n        \"#293551\"\n      ]\n    }\n  ]\n}\n[/block]\nYou can also look at the slice summary, which will indicate the status of your index and how many documents are present:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0f22128-12a_-_d7-apachesolr-query-results-1.png\",\n        \"12a - d7-apachesolr-query-results-1.png\",\n        645,\n        320,\n        \"#dbeae9\"\n      ]\n    }\n  ]\n}\n[/block]\nTo test Drupal, pick out a keyword that you can see in your index. Since my nodes were all randomly-generated, I grabbed the word \"dolor\" because it seemed to come up a few times. Go to your Drupal search and enter your chosen keyword. If everything is configured correctly, you should get a set of results:\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/400e8c9-13_-_d7-apachesolr-query-results-2.png\",\n        \"13 - d7-apachesolr-query-results-2.png\",\n        1046,\n        708,\n        \"#338fca\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Troubleshooting\"\n}\n[/block]\n### I get a 401 Unauthorized error when I try to index my documents ###\n\nYou have probably enabled authorization on this index. Making changes (writes, updates, deletes) to your index requires that your HMAC key be included in the request header. The ApacheSolr module does not have the capability of crafting a request in this way. There are three solutions: disable advanced authorization, hack the module to include the HMAC header and hard-code your key, or write a patch for the module that adds this cabability for end users and submit it to the maintainer for consideration.","excerpt":"Learn how to set up a Websolr index to be used with Drupal 7 and the Apache Solr module.","slug":"drupal-7-with-the-apachesolr-module","type":"basic","title":"Drupal 7 with the ApacheSolr module"}

Drupal 7 with the ApacheSolr module

Learn how to set up a Websolr index to be used with Drupal 7 and the Apache Solr module.

In this guide, we're going to cover the basics of setting up a Websolr index to be used with Drupal 7 and the ApacheSolr module. A few points to note before we get started: * This example uses Drupal 7.22 and ApacheSolr version 7.x-1.3. Your versions may vary; as long as the major versions are the same, you can reliably use this guide. * This guide is not meant to be an exhaustive tutorial on all of the things the ApacheSolr module can do. The goal here is to get you up and running quickly, then let you tune things as necessary. * If you run into issues while following this guide, make sure to check the "Troubleshooting" section at the bottom and see if a solution is addressed there. [block:api-header] { "type": "basic", "title": "Getting started" } [/block] For the purposes of this tutorial, I set up a vanilla Drupal 7 install. I used the Devel module to generate 50 nodes of random content so we would have something to index later. After my dummy content was created, I uninstalled and removed this module. I also downloaded the [apachesolr](https://drupal.org/project/apachesolr) module and extracted it to `sites/all/modules/apachesolr` Other than that, I did not add or change any module settings along the way. Your situation is probably different, but it shouldn't matter at this point. [block:image] { "images": [ { "image": [ "https://files.readme.io/40ca415-01_-_home.png", "01 - home.png", 1378, 874, "#3d85b4" ] } ] } [/block] Make sure you navigate to `admin/modules` and verify that the ApacheSolr module and its related modules have been activated: [block:image] { "images": [ { "image": [ "https://files.readme.io/6aa274d-02_-_modules.png", "02 - modules.png", 1148, 311, "#e9eae3" ] } ] } [/block] Great! That's all you need to get started. Next, we'll configure the Websolr index that will hold your documents. [block:api-header] { "type": "basic", "title": "Setting up the Websolr index" } [/block] Next, you'll want to [add a new slice](https://websolr.com/slices/new) to your websolr account. Give your index a descriptive name, select the server group nearest to your application, then select "Drupal ApacheSolr Search 7.x-1.1". Don't worry if the minor versions are different between your system and this tutorial: [block:image] { "images": [ { "image": [ "https://files.readme.io/e0c6118-03_-_d7-apachesolr-create-index.png", "03 - d7-apachesolr-create-index.png", 651, 377, "#ddebea" ] } ] } [/block] When this form has been filled out, go ahead and click "Create." Afterwards, you will be redirected to a page that shows the status of your index and will probably show a message about taking a few minutes to complete: [block:image] { "images": [ { "image": [ "https://files.readme.io/353261d-04_-_d7-apachesolr-create-index-2.png", "04 - d7-apachesolr-create-index-2.png", 645, 325, "#dbeae9" ] } ] } [/block] This is usually finished within a few minutes, so take a short break. When you come back, hit refresh to see the following: [block:image] { "images": [ { "image": [ "https://files.readme.io/0010d87-05_-_d7-apachesolr-create-index-3.png", "05 - d7-apachesolr-create-index-3.png", 650, 328, "#dbeae9" ] } ] } [/block] If you see a message that says your index looks ok, you're done. Occasionally provisioning errors will occur and you will see a message about taking a long time to provision your index. Try appending "/refreshing" to the page's URL and give it a minute or two. If that doesn't clear things up, you will need to open a [support ticket](http://help.websolr.com) and have the Support Team take a closer look. [block:api-header] { "type": "basic", "title": "Setting up the ApacheSolr Module" } [/block] Once your websolr index is up and running, it's time to configure the ApacheSolr module. Navigate to `admin/config/search/apachesolr/settings` and you should see something like this: [block:image] { "images": [ { "image": [ "https://files.readme.io/9601209-06_-_d7-apachesolr-configure-apachesolr.png", "06 - d7-apachesolr-configure-apachesolr.png", 1194, 402, "#ebebe4" ] } ] } [/block] This is the default setting that comes bundled with the module. Clicking on the "Edit" link will bring up the following form: [block:image] { "images": [ { "image": [ "https://files.readme.io/3187ea4-07_-_d7-apachesolr-configure-apachesolr-2.png", "07 - d7-apachesolr-configure-apachesolr-2.png", 1192, 554, "#e8e3d9" ] } ] } [/block] You will want the Solr server URL to point to the URL of the websolr index that you just created. Note that websolr communicates over the standard HTTP port 80, not 8080 or 8983 (standard ports for Tomcat and Jetty respectively). Consequently, you can leave out the port specification and your app will still be able to communicate with websolr. For example, my settings look like this: [block:image] { "images": [ { "image": [ "https://files.readme.io/b81bb3e-08_-_d7-apachesolr-configure-apachesolr-3.png", "08 - d7-apachesolr-configure-apachesolr-3.png", 1189, 555, "#e9e4da" ] } ] } [/block] Once you have your URL and a description set up, go ahead and click on "Test connection" to verify that everything is working. You should get a message that your site has contacted the Apache Solr server. If not, check your settings and try again. Once the connection has been verified, click on "Save." [block:image] { "images": [ { "image": [ "https://files.readme.io/0f1e383-09_-_d7-apachesolr-configure-apachesolr-4.png", "09 - d7-apachesolr-configure-apachesolr-4.png", 1179, 606, "#e6eae1" ] } ] } [/block] Next, click on the "Default Index" tab. You will see a few actions for indexing, reindexing and deleting the index. You will probably also see the message: "Error: No data was returned from the server." This is NOT an error. It is due to how the ApacheSolr module verifies a connection to the Solr server. Essentially, it requests some administrative functions which are blocked for security reasons by websolr. This [KB article](http://help.websolr.com/kb/common-problems/drupal-apachesolr-module-401-authorization-required) has more information. Basically, don't worry about it: [block:image] { "images": [ { "image": [ "https://files.readme.io/abc781b-10_-_d7-apachesolr-configure-apachesolr-5.png", "10 - d7-apachesolr-configure-apachesolr-5.png", 1194, 700, "#dadcd8" ] } ] } [/block] Click on the first option, "Index queued content." This will index a maximum of 50 documents (by default). You could also index all documents at this time, but that may take a while depending on how many documents you have.If everything went smoothly, you should get a message like the one below. If you see any errors (except for the previously-mentioned one about no data being returned from the server), double-check that your settings are correct and that the apachesolr module can communicate with websolr: [block:image] { "images": [ { "image": [ "https://files.readme.io/d42fd25-11_-_d7-apachesolr-configure-apachesolr-6.png", "11 - d7-apachesolr-configure-apachesolr-6.png", 1194, 698, "#193547" ] } ] } [/block] Finally, navigate to `admin/config/search/settings` and make sure that the ApacheSolr module is set to the default search module. You may also want to disable the other modules, especially if you don't need them: [block:image] { "images": [ { "image": [ "https://files.readme.io/f1f1b0d-09a_-_d7-apachesolr-configure-apachesolr-1.png", "09a - d7-apachesolr-configure-apachesolr-1.png", 1152, 365, "#d4d1c9" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Checking on your index" } [/block] After the apachesolr module has indicated a successful indexing of your documents, you can navigate to your websolr URL and append "/select" to it. For me, this was `http://ec2-west.websolr.com/solr/750f846502e/select` This will return the first set of documents in your index. If you don't see them right away after indexing, don't worry. For reasons of network performance and stability, all websolr indices have a 60 second commit time. This means your documents can take up to 60 seconds to show up in your index; if you don't see them right away, just wait a minute, then hit refresh: [block:image] { "images": [ { "image": [ "https://files.readme.io/01be15c-12_-_d7-apachesolr-query-results.png", "12 - d7-apachesolr-query-results.png", 1359, 840, "#293551" ] } ] } [/block] You can also look at the slice summary, which will indicate the status of your index and how many documents are present: [block:image] { "images": [ { "image": [ "https://files.readme.io/0f22128-12a_-_d7-apachesolr-query-results-1.png", "12a - d7-apachesolr-query-results-1.png", 645, 320, "#dbeae9" ] } ] } [/block] To test Drupal, pick out a keyword that you can see in your index. Since my nodes were all randomly-generated, I grabbed the word "dolor" because it seemed to come up a few times. Go to your Drupal search and enter your chosen keyword. If everything is configured correctly, you should get a set of results: [block:image] { "images": [ { "image": [ "https://files.readme.io/400e8c9-13_-_d7-apachesolr-query-results-2.png", "13 - d7-apachesolr-query-results-2.png", 1046, 708, "#338fca" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "Troubleshooting" } [/block] ### I get a 401 Unauthorized error when I try to index my documents ### You have probably enabled authorization on this index. Making changes (writes, updates, deletes) to your index requires that your HMAC key be included in the request header. The ApacheSolr module does not have the capability of crafting a request in this way. There are three solutions: disable advanced authorization, hack the module to include the HMAC header and hard-code your key, or write a patch for the module that adds this cabability for end users and submit it to the maintainer for consideration.