Configure DDEV with Apache Solr on Drupal 7 for Search API - solr

From #DamienMcKenna in Slack
Having problems creating a Solr instance with a D7 site. I copied the conf files to ~/.ddev/solr/conf but when Solr starts there is no default instance created. I ran ddev stop --remove-data --omit-snapshot and recreated the instance, but the instance still doesn't exist. When I go to the Solr UI to check the system it shows "no cores available", when I try to create one named "dev" it says:
Error CREATEing SolrCore 'dev': Unable to create core [dev] Caused by: Can't find resource 'solrconfig.xml' in classpath or '/opt/solr/server/solr/dev'

I had success on a Drupal 7 project using the example docker-compose-solr.yaml file from version 1.11.0 of DDEV.
Copy https://github.com/drud/ddev/blob/v1.11.0/pkg/servicetest/testdata/services/docker-compose.solr.yaml into your .ddev folder and ensure line 34 matches the solr version you're going to copy from step 2 below, eg solr: 6.6
Copy the files from sites/all/modules/contrib/search_api_solr/solr-conf/6.x/*.* into the .ddev/solr/conf folder.
Download and enable search_api_override module.
Add the following in settings.local.php:
// For ddev only.
$conf['search_api_override_mode'] = 'load';
$conf['search_api_override_servers']['content'] = array(
'name' => 'DDEV: Solr Server',
'options' => array(
'host' => 'solr',
'port' => '8983',
'path' => '/solr/dev',
'http_user' => '',
'http_pass' => '',
'excerpt' => 0,
'retrieve_data' => 1,
'highlight_data' => 0,
'http_method' => 'AUTO',
),
);
Also, ymmv. It may be better to only override the values you need individually… a la:
$conf['search_api_override_servers']['content']['options']['host'] = 'solr';
$conf['search_api_override_servers']['content']['options']['port'] = '8983';
$conf['search_api_override_servers']['content']['options']['host'] = '/solr/dev';
You may need to modify 'content' array index to match whatever you configured in Drupal 7 to be your Solr index's machine name.
Start ddev with ddev start.
NOTE, I place the Search API override values in sites/default/settings.local.php instead of what one would think to be the logical place (sites/default/settings.ddev.php) so as not to interfere with DDEV's own auto-generation of the latter file.
It would be cool if DDEV did this automatically in settings.ddev.php similar to how the DB service settings work, but AFAICT this level of integration is not there and likely never will be for Drupal 7. Firstly, because you need an additional module (search_api_override) that may or may not be present, and secondly because users have the ability to name their Solr server whatever they want, so it would be hard to automate that. E.g. $conf['search_api_override_servers']['content'] could be anything like: $conf['search_api_override_servers']['foo'].

Related

Guys i am getting error as below while copying the file from puppet master to agents

1.when i used "puppet agent -t" command in agents it's not retrieving from puppet server and getting the error as below.
2.the below code i have used in modules path:/etc/puppetlabs/code/environments/production/modules/mailx/manifests/init.pp and i have included this class in site.pp file as below.
Error: 1.I
/Stage[main]/Mailx/File[/etc/mail.rc]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/mailx/mail.rc
file { '/etc/mail.rc':
ensure => present,
mode => '0644',
owner => 'root',
group => 'root',
source => 'puppet:///modules/mailx/mail.rc',
}
node 'default', {
include mailx
}
Your code will be much easier to read if you present it like this.
#/etc/puppetlabs/code/environments/production/modules/init.pp
class mailx {
file { '/etc/mail.rc':
ensure => present,
mode => '0644',
owner => 'root',
group => 'root',
source => 'puppet:///modules/mailx/mail.rc',
}
}
And then the file
#/etc/puppetlabs/code/environments/production/modules/mailx/files/mail.rc
set smtp=your.smtp.server
set from="from email address"
The module should be in
/etc/puppetlabs/code/environments/production/modules/mailx/manifests/init.pp
Notice the "production" after the environments.
It may have just been a typo when you put the path in to here but you spelt puppetlabs as puppelabc.
And the file should be here
/etc/puppetlabs/code/environments/production/modules/mailx/files/mail.rc
Each directory under the environment directory is an environment and that error says Puppet is looking in the production environment for that file.

Solr 8 upgrade and stream.body

I'm upgrading Solr from 6.x to 8.x. In the past, we used to build our request thusly in our PHP script:
$aPostData = array(
'stream.body' => '{"add": {"doc":{...stuff here...}}',
'commit' => 'true',
'collection' => 'mycollection',
'expandMacros' => 'false'
);
$oBody = new \http\Message\Body();
$oBody->addForm($aPostData);
sending it to our Solr server at /solr/mycollection/update/json. That worked just fine in 6.x but now that I've upgraded to 8.x, I'm receiving the following response from Solr
{
"responseHeader":{
"status":400,
"QTime":1
},
"error":{
"metadata":[
"error-class","org.apache.solr.common.SolrException",
"root-error-class","org.apache.solr.common.SolrException"],
"msg":"missing content stream",
"code":400
}
}
Digging around I ran across the following
https://issues.apache.org/jira/browse/SOLR-10748
and
Solr error - Stream Body is disabled
I tried following the suggestions of both answers. For the first one, I now see a file called "configoverlay.json" in my ./conf directory and it has those settings. For the second answer, I set it up so my requestParsers node had those attributes. However, neither worked. I've searched around but at this point I'm at my wits end. How can I make it so that I can continue using "stream.body"? If I shouldn't be using "stream.body" is there some other request var that I can/should use when sending my data? I couldn't find anything in the documentation. Perhaps I was looking in the wrong place?
Any help would be greatly appreciated.
thnx,
Christoph

Access Sql Server through Ruby Active Record JDBC

I've been attempting to connect to a remote JDBC/SqlServer database using Active Record in Ruby (specifically JRuby). Here is my code:
require 'activerecord'
require 'activerecord-jdbc-adapter'
ActiveRecord::Base.establish_connection(
:adapter => 'sqlserver',
:username => '<username>',
:password => '<password>',
:database => '<database_name>',
:url => '<database_url>',
)
#connection = ActiveRecord::Base.connection
puts #connection
I've also put 'jdbc' as the adapter, and that also did not work.
And here is an abbreviated version of the error I am getting:
NameError: cannot load Java class com.microsoft.sqlserver.jdbc.SQLServerDriver
for_name at org/jruby/javasupport/JavaClass.java:286
get_proxy_class at org/jruby/javasupport/JavaUtilities.java:34
block in java_import at uri:classloader:/jruby/java/core_ext/object.rb:49
map at org/jruby/RubyArray.java:2486
java_import at uri:classloader:/jruby/java/core_ext/object.rb:36
block in driver_class at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.23/lib/arjdbc/jdbc/driver.rb:24
module_eval at org/jruby/RubyModule.java:2833
block in driver_class at C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/activerecord-jdbc-adapter-1.3.23/lib/arjdbc/jdbc/driver.rb:23
synchronized at org/jruby/javasupport/JavaObject.java:257
It's not so much a specific problem but more that I'm just unsure where to go from here. Using the 'activerecord-sqlserver-adapter' in pure Ruby doesn't work because of the JDBC on the server. (I might be misusing the terms here, I'm rather unfamiliar with how databases work.)
However, the jdbc/sqlserver gems seem to be not well-supported or out of date. There's probably no silver bullet for this, but any kind of direction would be of enormous help.
You still need to require 'active_record', no?
And I am not sure you need the require 'arel'. That is the low level sql builder/formatter implemented by active_record.
require 'active_record'
require 'activerecord-jdbc-adapter'
ActiveRecord::Base.pluralize_table_names = false
ActiveRecord::Base.establish_connection(
:adapter => "sqlserver",
:host => "SqlServerHostName",
:database => "HostDbName"
)

installing tomcat7 using puppet on CentOs

so my idea was to install tomcat7 using puppet, and then deploy the war file of Solr as a web app. Here is what i found.
There are many tomcat7 modules on puppet forge but none of them work out of box, and i am not sure if any of them actually work and a lot of them pertains to have code as documentation.
Take puppet module install fhuertas-tomcat7 as first example:
installs fhuertas-tomcat7 (v0.0.1)
i get an error, when i run:
sudo puppet apply --modulepath=/home/qa/puppet_qa/modules/ -e "include tomcat7" --debug
Error: Could not find data item service_path in any Hiera data file and no default supplied
and similar scenario follows for :
puppet module install llehmijo-tomcat7_rhel ( no longer maintained )
https://github.com/Spredzy/puppet-tomcat7 ( claims to be for CentOs ) but has an Apt (apt for centos ??) pre-requisite, plus it did not install either.
All i want to do is to install tomcat7 via puppet, and then install Solr. seems to be a simple request. Meanwhile i am working on my own to resolve the exact issue, and was able to install and run tomcat7, but not sure how i can install tomcat-users.xml
here is a portion of my init.pp
exec {'start service':
command => 'sh "startup.sh"',
cwd => "/usr/share/apache-tomcat-7.0.42/bin",
path => '/usr/share/apache-tomcat-7.0.42/bin/:/usr/bin:/bin',
#require => File['/usr/share/apache-tomcat-7.0.42/conf/tomcat-users.xml']
}
so if i un-comment the require => File[]
Error: Could not find dependency File[/usr/share/apache-tomcat-7.0.42/conf/tomcat-users.xml] for Exec[start service]
file { "/etc/tomcat7/tomcat-users.xml":
owner => 'root',
require => Package['tomcat'],
notify => Service['tomcat'],
content => template('tomcat/tomcat-users.xml.erb')
}
This works, as for the modules not working on puppet forge , and github, i think there is no resolution as if not working then these modules can be taken as guidelines, or hints.
I used the supported one https://forge.puppetlabs.com/puppetlabs/tomcat and following the examples everything was properly installed using packages (at least on Ubuntu). It is also possible to install it from source.
https://github.com/puppetlabs/puppetlabs-tomcat/tree/master/examples. See the example below:
class { 'java': }
class { 'tomcat':
install_from_source => false,
user => 'tomcat7',
require => Class['java']
}
tomcat::instance { 'tomcat7':
package_name => 'tomcat7',
require => Class['tomcat']
}->
tomcat::instance { 'tomcat7-admin':
package_name => 'tomcat7-admin',
}->
tomcat::config::server::tomcat_users {
'tomcat-admin':
catalina_base => '/var/lib/tomcat7',
element => 'user',
password => 'test',
roles => ['manager-gui','admin'];
'deployer':
catalina_base => '/var/lib/tomcat7',
element => 'user',
password => 'deployer',
roles => ['manager-script'];
}->
tomcat::service { 'tomcat7':
service_ensure => running,
catalina_base => '/var/lib/tomcat7',
require => Tomcat::Instance['tomcat7']
}

cakephp WebTechNick paypal plugin(missing controller)

I have downloaded WebTechNick's PayPal plugin and copied the files
into /app/plugins/paypal_ipn (exactly as per the instructions). I have
amended /app/config/routes.php to include the routes for the plugin
(these are copied straight from the installation instructions).
When I access http//:[mysite]/paypal_ipn I am getting a
missing controller error:
Error: PaypalIpnController could not be found.
Error: Create the class PaypalIpnController below in file: app/
controllers/paypal_ipn_controller.php
I'm baffled as I have followed conventions yet this isn't working. I
have other plugins working as expected.
What am I doing wrong?
thanks
i would not use this route (besides, its optional)
Router::connect('/paypal_ipn/:action/*', array('admin' => 'true', 'plugin' => 'paypal_ipn', 'controller' => 'instant_payment_notifications', 'action' => 'index'));
I want my admin stuff to be in /admin/... not having one rouge plugin doing something else
after removing that you should have the following available
site.com/admin/paypal_ipn/paypal_items (shows index like always)
site.com/admin/paypal_ipn/paypal_items/index
site.com/admin/paypal_ipn/paypal_items/view/$id
site.com/admin/paypal_ipn/paypal_items/add
site.com/admin/paypal_ipn/paypal_items/edit/$id
site.com/admin/paypal_ipn/paypal_items/delete/$id
and
site.com/paypal_ipn/instant_payment_notifications/process (need to post to this one)
and
site.com/admin/paypal_ipn/instant_payment_notifications (shows index like always)
site.com/admin/paypal_ipn/instant_payment_notifications/index
site.com/admin/paypal_ipn/instant_payment_notifications/view/$id
site.com/admin/paypal_ipn/instant_payment_notifications/add
site.com/admin/paypal_ipn/instant_payment_notifications/edit/$id
site.com/admin/paypal_ipn/instant_payment_notifications/delete/$id
This is really old, but the selected answer didn't help solve my problem and this thread is the only one that I was able to find.
The issue is that by default, cakephp (as of 2.5.4) does not enable admin prefixing. If (like me) you're not familiar with routing or prefixing, I suggest reading the below links:
Routing: http://book.cakephp.org/2.0/en/development/routing.html
Prefixing: http://book.cakephp.org/2.0/en/development/routing.html#prefix-routing
But, the quick fix to this (assuming your fine with this plugins admin routing process) is to uncomment the admin prefixing line in your core.php. DO NOT TRY ADDING THIS TO routes.php. It won't work. Rather look around line 152 in /app/Config/core.php and change
//Configure::write('Routing.prefixes', array('admin'));
to
Configure::write('Routing.prefixes', array('admin'));
I assume you have added
var $components = array('PluginName.Example'); (adjust the values)
to your (app_)controller?

Resources