diff --git a/Drupal_Apache_Solr_Service.php b/Drupal_Apache_Solr_Service.php index 4558f6d..0dac1cf 100644 --- a/Drupal_Apache_Solr_Service.php +++ b/Drupal_Apache_Solr_Service.php @@ -247,7 +247,7 @@ class DrupalApacheSolrService implements DrupalApacheSolrServiceInterface { return $this->luke[$num_terms]; } - protected function getSolrVersion() { + public function getSolrVersion() { $system_info = $this->getSystemInfo(); // Get our solr version number if (isset($system_info->lucene->{'solr-spec-version'})) { diff --git a/solr-conf/solr-3.x/schema.xml b/solr-conf/solr-3.x/schema.xml index 2cebb36..663a3d1 100644 --- a/solr-conf/solr-3.x/schema.xml +++ b/solr-conf/solr-3.x/schema.xml @@ -10,7 +10,7 @@ http://wiki.apache.org/solr/SchemaXml --> - + + see: http://www.lucidimagination.com/blog/2009/09/08/auto-suggest-from-popular-queries-using-edgengrams/ + --> - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - @@ -316,7 +316,7 @@ + --> @@ -325,200 +325,222 @@ - + - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - id - - - content - - - + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id + + + content + + + diff --git a/solr-conf/solr-3.x/schema_extra_fields.xml b/solr-conf/solr-3.x/schema_extra_fields.xml new file mode 100644 index 0000000..9ecd5f4 --- /dev/null +++ b/solr-conf/solr-3.x/schema_extra_fields.xml @@ -0,0 +1,23 @@ + + + + diff --git a/solr-conf/solr-3.x/schema_extra_types.xml b/solr-conf/solr-3.x/schema_extra_types.xml new file mode 100644 index 0000000..e82072e --- /dev/null +++ b/solr-conf/solr-3.x/schema_extra_types.xml @@ -0,0 +1,30 @@ + + + + diff --git a/solr-conf/solr-3.x/solrconfig.xml b/solr-conf/solr-3.x/solrconfig.xml index ade4fcd..ce3fab0 100644 --- a/solr-conf/solr-3.x/solrconfig.xml +++ b/solr-conf/solr-3.x/solrconfig.xml @@ -16,482 +16,853 @@ limitations under the License. --> - + + + + + + ${solr.abortOnConfigurationError:true} + - LUCENE_35 - - ${solr.abortOnConfigurationError:true} + - + All directories and paths are resolved relative to the + instanceDir. - - - false + If a "./lib" directory exists in your instanceDir, all files + found in it are included as if you had used the following + syntax... + + + --> - 10 - + + + + - --> - - + + + + + + + + + - If both ramBufferSizeMB and maxBufferedDocs is set, then Lucene will flush based on whichever limit is hit first. + + + + - 32 - 2147483647 - 20000 - 1000 - 10000 + - - - - + solr.RAMDirectoryFactory is memory based, not + persistent, and doesn't work with replication. + --> + - - + + + + false + + 4 + + 32 + + + + 2147483647 + 100000 + 1000 + + + - single = SingleInstanceLockFactory - suggested for a read-only index - or when there is no possibility of another process trying - to modify the index. - native = NativeFSLockFactory - simple = SimpleFSLockFactory + + + + single + + + + - + false 32 - 4 - 2147483647 - 20000 + 10 + + false + + + true - - - false - + 1 + + 0 + - + + false - If you want to connect to a particular server, specify the agentId - e.g. + - If you want to start a new MBeanServer, specify the serviceUrl - e.g + - + For more details see http://wiki.apache.org/solr/SolrJmx + --> + + + + + - + - + - - 2000 - 120000 + Perform a automatically under certain conditions. + Instead of enabling autoCommit, consider using "commitWithin" + when adding documents. + + http://wiki.apache.org/solr/UpdateXmlMessages + + maxDocs - Maximum number of documents to add since the last + commit before automatically triggering a new commit. + + maxTime - Maximum amount of time that is allowed to pass + since a document was added before automaticly + triggering a new commit. + --> + + 10000 + 120000 + + - + + + + + - + + - - - + 1024 - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + true - - - - + - 50 - - - 200 - - - - - + A possible optimization that attempts to use a filter to + satisfy a search. If the requested sort does not include + score, then the filterCache will be checked for a filter + matching the query. If found, the filter will be used as the + source of document ids, and then the sort will be applied to + that. + + For most situations, this will not be useful unless you + frequently get the same search repeatedly with different sort + options, and none of them ever use "score" + --> + + + + 20 + + + 200 + + + local query request for each NamedList in sequence. + --> - solr 0 10 - rocks 0 10 - static newSearcher warming query from solrconfig.xml + - - - fast_warm 0 10 - static firstSearcher warming query from solrconfig.xml + + solr rocks010 + - + false - + 2 - - - - - - - - - - - + enableRemoteStreaming - enables use of the stream.file + and stream.url parameters for specifying remote streams. + + multipartUploadLimitInKB - specifies the max size of + Multipart File Uploads that Solr will allow in a Request. + + *** WARNING *** + The settings below authorize Solr to fetch remote files, You + should make sure your system has some authentication before + using enableRemoteStreaming="true" + + --> + + + + + + + + + - - - + http://wiki.apache.org/solr/SolrRequestHandler + + incoming queries will be dispatched to the correct handler + based on the path or the qt (query type) param. + + Names starting with a '/' are accessed with the a path equal to + the registered name. Names without a leading '/' are accessed + with: http://host/app/[core/]select?qt=name + + If a /select request is processed with out a qt param + specified, the requestHandler that declares default="true" will + be used. + + If a Request Handler is declared with startup="lazy", then it will + not be initialized until the first request that uses it. + + --> + + + + - - + --> + + + + + + + + - - - - - - - - - dismax - explicit - true - - + - + + + + + + + + + + + + - dismax - explicit - true - 0.01 - - content^2.0 - - 15 - - - 1 - *:* - - - true - content - 3 - true - - teaser - 256 - - - - + edismax + explicit + true + 0.01 + + ${pinkPony.timeAllowed:-1} + *:* + + false - + true false @@ -503,7 +874,7 @@ + when performing moreLikeThis requests.--> 1 @@ -512,232 +883,701 @@ 15 20 false - - + + ${mlt.timeAllowed:2000} + + + + + + + - By default, the following components are avaliable: + + - - - - - - + + - Default configuration in a requestHandler would look like: - - query - facet - mlt - highlight - stats - debug - + + + + + text + true + ignored_ + + + true + links + ignored_ + + - - myLastComponentName - + + + + + + + + + - - + + + + + + - - default - spell - ./spellchecker1 - true + + + + pinkPony + solrpingquery - - jarowinkler - spell - - org.apache.lucene.search.spell.JaroWinklerDistance - ./spellchecker2 - true + + all + - + + + + explicit + true + + + + - - - string - elevate.xml - + http://wiki.apache.org/solr/SolrReplication - - + In the example below, remove the section if + this is just a slave and remove the section + if this is just a master. + --> + + + ${enable.master:false} + commit + startup + ${confFiles} + + + ${enable.slave:false} + ${masterCoreUrl}/replication + ${pollTime:00:00:60} + + + + + + + - explicit + false + false + 1 - elevator + spellcheck + + + + - + + + true + + + tvComponent + + - - + - + This relies on third party jars which are notincluded in the + release. To use this component (and the "/clustering" handler) + Those jars will need to be downloaded, and you'll need to set + the solr.cluster.enabled system property when running solr... + java -Dsolr.clustering.enabled=true -jar start.jar + --> + + + + + + + + - + + + + + + + - + + stc + org.carrot2.clustering.stc.STCClusteringAlgorithm + + --> - - + + + + + + + + + + + + + + + + + - - - admin-extra.html - scripts.conf - xslt/example.xsl - xslt/example_atom.xsl - xslt/example_rss.xsl - xslt/luke.xsl - + http://wiki.apache.org/solr/TermsComponent + + A component to return terms and document frequency of those + terms + --> + + + + + + true + + + terms + - - + + + + + string + elevate.xml + + + + - explicit - true + explicit + + elevator + - - - - - - 100 - - + - - - - 70 - - 0.5 - - [-\w ,/\n\"']{20,200} - - + http://wiki.apache.org/solr/HighlightingParameters + --> + + + + + + + 100 + + + + + + + + 70 + + 0.5 + + [-\w ,/\n\"']{20,200} + + + + + + + ]]> + ]]> + + + + + + + + + + + + + + + + + + + + + ,, + ,, + ,, + ,, + ,]]> + ]]> + + + + + + 10 + .,!? + + + + + + + WORD + + + en + US + + + + - - - - ]]> - ]]> - - - + + + An example dedup update processor that creates the "id" field + on the fly based on the hash code of some other fields. This + example has overwriteDupes set to false since we are using the + id field as the signatureField and Solr will maintain + uniqueness based on that anyway. + + --> + + + + + + + + + + + + text/plain; charset=UTF-8 + + + + + + - + every xsltCacheLifetimeSeconds. + --> + 5 + + http://wiki.apache.org/solr/SolrQuerySyntax - + Multiple QParserPlugins can be registered by name, and then + used in either the "defType" param for the QueryComponent (used + by SearchHandler) or in LocalParams + --> + + - - - solr - + + + + + + *:* + + + + + + + + diff --git a/solr-conf/solr-3.x/solrconfig_extra.xml b/solr-conf/solr-3.x/solrconfig_extra.xml new file mode 100644 index 0000000..5ce04b8 --- /dev/null +++ b/solr-conf/solr-3.x/solrconfig_extra.xml @@ -0,0 +1,79 @@ + + + +textSpell + + + + + + default + content + spellchecker + + + + + + + + + + + + + + + diff --git a/solr-conf/solr-3.x/solrcore.properties b/solr-conf/solr-3.x/solrcore.properties new file mode 100644 index 0000000..0f3933d --- /dev/null +++ b/solr-conf/solr-3.x/solrcore.properties @@ -0,0 +1,10 @@ +#solrcore.properties for this specific core +enable.master=false +enable.slave=false +pollTime=00:00:60 +masterCoreUrl=http://localhost:8983/solr +confFiles=schema.xml,mapping-ISOLatin1Accent.txt,protwords.txt,stopwords.txt,synonyms.txt,elevate.xml +mlt.timeAllowed=2000 +# You should not set your luceneVersion to anything lower then your Solr Version +luceneVersion=LUCENE_35 +pinkPony.timeAllowed=-1 diff --git a/solr-conf/solr-4.x/schema.xml b/solr-conf/solr-4.x/schema.xml index eeb25b1..f1a489f 100644 --- a/solr-conf/solr-4.x/schema.xml +++ b/solr-conf/solr-4.x/schema.xml @@ -331,13 +331,12 @@ - - - - - + + + + - - - - - + + + + diff --git a/solr-conf/solr-4.x/schema_extra_fields.xml b/solr-conf/solr-4.x/schema_extra_fields.xml new file mode 100644 index 0000000..9ecd5f4 --- /dev/null +++ b/solr-conf/solr-4.x/schema_extra_fields.xml @@ -0,0 +1,23 @@ + + + + diff --git a/solr-conf/solr-4.x/schema_extra_types.xml b/solr-conf/solr-4.x/schema_extra_types.xml new file mode 100644 index 0000000..e82072e --- /dev/null +++ b/solr-conf/solr-4.x/schema_extra_types.xml @@ -0,0 +1,30 @@ + + + + diff --git a/solr-conf/solr-4.x/solrconfig.xml b/solr-conf/solr-4.x/solrconfig.xml index df21783..7750bd5 100644 --- a/solr-conf/solr-4.x/solrconfig.xml +++ b/solr-conf/solr-4.x/solrconfig.xml @@ -1125,73 +1125,6 @@ --> - - - - textSpell - - - - - - default - name - spellchecker - - - - - - - - - - - - - + + + + + diff --git a/solr-conf/solr-4.x/solrconfig_extra.xml b/solr-conf/solr-4.x/solrconfig_extra.xml new file mode 100644 index 0000000..5ce04b8 --- /dev/null +++ b/solr-conf/solr-4.x/solrconfig_extra.xml @@ -0,0 +1,79 @@ + + + +textSpell + + + + + + default + content + spellchecker + + + + + + + + + + + + + + + diff --git a/tests/solr_index_and_search.test b/tests/solr_index_and_search.test index e449ef5..222502c 100755 --- a/tests/solr_index_and_search.test +++ b/tests/solr_index_and_search.test @@ -24,31 +24,47 @@ abstract class AbstractDrupalSolrOnlineWebTestCase extends DrupalWebTestCase { } function setUpSolr() { - $patterns = func_get_args(); - // Load the default server. $env_id = apachesolr_default_environment(); $environment = apachesolr_environment_load($env_id); + $this->base_solr_url = $environment['url']; + // Because we are in a clean environment, this will always be the default // http://localhost:8983/solr - $this->core_admin_url = "{$environment['url']}/admin/cores"; + $this->core_admin_url = "{$this->base_solr_url}/admin/cores"; // The core admin url will give a valid response if the // Solr server is running locally. if ($this->coreAdminAvailable()) { + // We will use a core named after the simpletest prefix. $environment['url'] .= '/' . $this->databasePrefix; - $filesdir = variable_get('file_public_path'); + $filesdir = file_directory_temp(); // Create our Solr core directory. - mkdir("$filesdir/solr", 0777, TRUE); - mkdir("$filesdir/solr/conf"); - + drupal_mkdir("{$filesdir}/solr", 0777, TRUE); // Our temporary core is located here. - $instancedir = realpath("$filesdir/solr"); + $instancedir = realpath($filesdir . "/solr"); + + // use the Solr version confs where appropriate. + $version = $this->getSolrVersion(); + if (isset($version) && $version == 3) { + $conf_path = dirname(__FILE__) . '/../solr-conf/solr-3.x/*'; + } + elseif (isset($version) && $version == 4) { + $conf_path = dirname(__FILE__) . '/../solr-conf/solr-4.x/*'; + } + else { + $conf_path = dirname(__FILE__) . '/../solr-conf/solr-1.4/*'; + } + + $patterns = array( + $conf_path, + dirname(__FILE__) . '/conf/*', + ); // Copy all files in solr-conf dir to our temporary solr core. - // @todo - use the Solr 3.x conf where appropriate. + drupal_mkdir("{$instancedir}/conf", 0777, TRUE); foreach ($patterns as $pattern) { foreach (glob($pattern) as $conf_file) { copy($conf_file, "$instancedir/conf/" . basename($conf_file)); @@ -61,6 +77,10 @@ abstract class AbstractDrupalSolrOnlineWebTestCase extends DrupalWebTestCase { // @todo - use solrcore.properties file for 3.x. file_put_contents("$instancedir/conf/solrconfig.xml", preg_replace('@[0-9]+@', '1000', $contents)); + // hard chmod -R because it seems drupal dirs are too restricted in a + // testing environment + system("chmod -R 777 {$instancedir}"); + $query['name'] = $this->databasePrefix; $query['instanceDir'] = $instancedir; $created = $this->coreAdmin('CREATE', $query); @@ -88,16 +108,32 @@ abstract class AbstractDrupalSolrOnlineWebTestCase extends DrupalWebTestCase { return ($result->code == 200 && empty($result->error)); } + protected function getSolrVersion() { + $status = $this->coreAdmin('STATUS'); + foreach($status['status'] as $core_id => $core) { + $solr = new DrupalApacheSolrService($this->base_solr_url . '/' . $core_id); + $version = $solr->getSolrVersion(); + if (!empty($version)) { + return $version; + } + else { + return "1"; + } + } + } + /** * Helper function to invoke core admin actions. */ protected function coreAdmin($action, $query = array()) { $query['action'] = $action; $query['wt'] = 'json'; - $query['indent'] = '1'; - $this->drupalGet($this->core_admin_url, array('query' => $query)); - if ($this->assertResponse(200)) { - return json_decode($this->drupalGetContent(), TRUE); + $url = url($this->core_admin_url, array('query' => $query)); + $options['timeout'] = 2; + $result = drupal_http_request($url, $options); + + if ($result->code == 200) { + return json_decode($result->data, TRUE); } else { return FALSE; @@ -115,8 +151,17 @@ abstract class AbstractDrupalSolrOnlineWebTestCase extends DrupalWebTestCase { function tearDown() { // Workaround for drupal.org test bot if ($this->solr_available) { - // Unload the Solr core. - $this->coreAdmin('UNLOAD', array('core' => $this->databasePrefix)); + // Unload the Solr core & delete all files + $query = array( + 'core' => $this->databasePrefix, + 'deleteIndex' => 'true', + 'deleteDataDir' => 'true', + 'deleteInstanceDir' => 'true' + ); + // This is currently broken due to + // https://issues.apache.org/jira/browse/SOLR-3586 + $this->coreAdmin('UNLOAD', $query); + } parent::tearDown(); } @@ -129,11 +174,7 @@ class DrupalSolrOnlineWebTestCase extends AbstractDrupalSolrOnlineWebTestCase { */ function setUp() { parent::setUp(); - parent::setUpSolr( - // The Solr 1.4 conf will work in both 1.4 and 3.5. - dirname(__FILE__) . '/../solr-conf/solr-1.4/*', - dirname(__FILE__) . '/conf/*' - ); + parent::setUpSolr(); } } @@ -153,11 +194,11 @@ class DrupalSolrMatchTestCase extends DrupalSolrOnlineWebTestCase { function testMatching() { if ($this->solr_available) { // workaround for drupal.org test bot $this->assertTrue($this->solr->ping(), "The Server could be Pinged"); - $response = $this->solr->search("*:*", array('qt' => 'standard')); + $response = $this->solr->search("*:*", array()); $response = $response->response; $this->assertEqual($response->numFound, 0, "There should not be any documents in the index"); $this->populateIndex(7); - $response = $this->solr->search("*:*", array('qt' => 'standard')); + $response = $this->solr->search("*:*", array()); $response = $response->response; $this->assertEqual($response->numFound, 7, "There should be 7 documents in the index"); $this->_testQueries(); @@ -265,7 +306,7 @@ class DrupalSolrMatchTestCase extends DrupalSolrOnlineWebTestCase { '"am minim veniam" -"dolore cillum"' => array(5, 6, 7), ); foreach ($queries as $query => $results) { - $response = $this->solr->search($query, array('qt' => 'standard')); + $response = $this->solr->search($query, array()); $this->_testQueryMatching($query, $response->response->docs, $results); //@TODO: We might get to this later #$this->_testQueryScores($query, $response->responses->docs, $results);