Misty thoughts

13Jul/100

Setting up Solr for Drupal under tomcat

Disclaimer: This method will probably not work for all servers running tomcat, it is more a personal guide then a general one.

Solr is a "popular, blazing fast open source enterprise search platform from the Apache Lucene project". Drupal search has traditionally been less then adequate. Using Solr to index and search you Drupal site is therefore quite helpful.

To start, download the Solr package (link) and the Solr drupal module (link). the current standard distribution is Solr 1.4 and Drupal 6.
Unarchive the tar files in a location that is reachable from your server.

We will assume that tomcat is installed in /opt/tomcat

In the Solr package there is an example application. That is the Solr application we are going to use. If you can write your own, you probably don't need this tutorial.

Step 1:
Copy the example application, found in the solr package under example/webapps to the tomecat webapps folder which should be /opt/tomcat/webapps. when copying the file rename it to something other the solr. this will enable you to have multiplie solr installations running under one Tomcat container. We will assume the app is renamed new_solr_inst. If you are in the tomcat root folder the command should like like this:
cp /path/to/solr/package/apache-solr-1.4.0/apache-solr-1.4.0/example/webapps/solr.war webapps/new_solr_inst.war

Tomcat will pick up the war file and open it automatically after a restart.

Step 2:
In the tomcat root folder create a folder to hold your Solr configuration and data.
mkdir new_solr_inst
Copy the example app configuration into that folder
cp -R /path/to/solr/package/apache-solr-1.4.0/apache-solr-1.4.0/example/solr/* new_solr_inst

Step 3:
You need to replace the original schema.xml and solrconfig.xml with the ones provided by the drupal module. Copy these two files to your Solr configuration folder. Assuming you are currently at the tomcat root folder
cp /path/to/solr/module/schema.xml new_solr_inst/conf
cp /path/to/solr/module/solrconfig.xml new_solr_inst/conf
The Solr app is now ready for use.

Step 4:
The last step is needed to inform Tomcat about the app and its settings. Go to conf/Catalina/localhost and create the file new_solr_inst.xml. In that file fill the following content:

<Context docBase="/opt/tomcat/webapps/new_solr_inst.war" debug="0" privileged="true" allowLinking="true" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="/opt/tomcat/new_solr_inst" override="true" />
</Context>

Step 5:
You need to restart tomcat
/opt/tomcat/bin/shutdown.sh
/opt/tomcat/bin/startup.sh
And your Solr should be running. There are three tests we can use to check everything went well.

  • Tomcat has opened the war file. There is now a folder new_solr_inst in the webapps folder of Tomcat.
  • Solr has made a data directory in the Solr home folder (that is /opt/tomcat/new_solr_inst)
  • In your browser go to the Solr app http://domain:tomcat_port/new_solr_inst and you should see a welcome screen

If all is well you are ready to combine this Solr installation with your Drupal

Step 6:
Activate the Apache-Solr module and go to the Solr module settings page admin/settings/apachesolr
Assuming tomcat and drupal are running on the same server fill in localhost as the host name, fill in the port tomcat is running on and solr path should be your app name in the tomcat webapps folder. In our case is it new_solr_inst.

Save the settings. Drupal should inform you that a connection is made with Solr

Notes

  • It is not nessecary to put the app configuration in the Tomcat root folder. you can probably (though I have not tested this) place it anywhere you want. you do need to make sure that the environment tag in the Tomact configuration file (the one in the conf/Catalina/localhost folder) is pointing to the right place.
  • If you make changes to the schema you may need to dump all the indices Solr has made. you can do this via the Drupal admin interface for the Solr module.
18May/090

A photo a day for a year

The sun reflecting on the Hooglandsekerk as seem from Aharale & Geiske's window

The sun reflecting on the Hogelandsekerk as seen from Aharale & Geiske's window

A few days ago I came upon this idea and I really liked it. Each day, one photo, with one or two sentences, for a whole year. It helps you remember each and every day in that year, while making you a better photographer. I found this picture to be a good starting picture.
Yesterday I was feeling down about loosing two ships in Eve-online Today, I am celebrating this world, and starting on what I believe to be a great experiment in living.

Tagged as: , No Comments
25Apr/080

Cascade delete in MySQL

Now that I am actually getting payed to program instead of paying to program, I find myself in greater need of practical information. Putting some of it on my blog will help me keep all the knowledge in one place. To start off, I'll mention Cascading delete in SQL.
In the database schema there are 3 tables used to store different objects. As there is a many to many relationship between the the objects, there are relation tables.

Basic database layout

Using cascading delete I can define that if an object is removed from its table, all relation tables entries with that object id are also removed. Quite handy. the way this achieves is MySQL is through the use of foreign keys. If I define in the table members the unique id of a user as a foreign key I can also define tell the RDMS to delete the entries in members where that foreign key exist. Here is an example of the definitions:


CREATE TABLE members (
usr_id VARCHAR(30) NOT NULL,
grp_id VARCHAR(30) NOT NULL,
FOREIGN KEY usr_id REFERENCE user (usr_id) ON DELETE CASCADE,
FOREIGN KEY grp_id REFERENCE group (grp_id) ON DELETE CASCADE);

As you can see the table is created normally by defining the fields, then the foreign keys are named. The REFERENCE shows to which column in what table they refer to.

Filed under: programming, work No Comments
17Mar/080

The first two weeks of work

It has now been two weeks since I started working so I figured it might be a good time for a post about how things are.

Before I started working all I heard from the working people is how they miss the student time. How much more demanding working life is. It won't be an overstatment to say I went to my first day a bit worried.

My first day was like Christmas.  I got a mobile phone, a laptop and a car. And that was pretty much it. The next two days have been just as nice. Together with all the people who started working for Getronics-Pinkroccade this month we had a 2 day into plan. Some presentation, some group talks, and beer. Yes every building in the company has its own beer tap with a barman. I like that. Did I mention, its free beer? The people I met were intellegent, interesting and fun. If this is how most people in the company are, I made a good choice coming to work here.

From the forth day on, and for the coming 2 weeks I'm in courses in Amersfoort. Its quite relaxed. I'm doing the courses alone, with a tutor I can turn to for questions. My tempo is quite high (im going almost at twice the expected rate) so I might be finished earlier then expected.

After I finish the courses I have a month of stage to build some web app (interesting ideas for what exactly are welcome). Then it will be time to actually work on real projects.

Filed under: Me, work No Comments
16Oct/07Off

Found a job

In a streak of luck and some good talks, I got a job at Pinkroccade. I will be following the Young IT professional program they offer. Starting on the 1/3/2008. this should give me a month to visit Israel, and have some time with my brothers in the Netherlands before starting to work full time.

Filed under: work Comments Off