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.
28May/100

jQuery animation problem in ie7

For one of our projects, I was creating a photo bar. When the mouse was over one of the photos it was ment to increase in size and decrease back to original size when the mouse left. Unfortunately the client for which this was developed uses ie7 exclusively. This has brought two problems:
1. ie7 does not support the mouseleave event. I needed to replace it with mouseout event.
2. ie7 does not accept the position property in the jQuery animate function. Giving the position as a parameter will cause an error.

11May/100

Namespacing and setTimeOut in Javascript

It is good practice to put all of your javascript code in its own namespace. When doing so in combination with setTimeOut timer function it is important to remember that the object evoking the function will be the DOM window and not your namespace object. Therefore it is needed to add the namespace before the name of the function called.

25Feb/100

Getting session ID in Drupal 6

Drupal saves its sessions in the sessions table. One can always query they table to get the session ID. There is however a faster way.
If the user is logged it, the session id can be found with the following code:

global $user;
$user->sid;

In any case the session id can also be read from the cookie:

$_COOKIE[session_name()];
Tagged as: , No Comments
23Feb/100

Theming a form in Drupal 6

Form theming in drupal 6 is quite flexible. One of the nicest tricks is the ability to theme the form in stages. Calling drupal_render on a part of the form will not only return the rendered version of it, but it will also mark that part as rendered so that when you call the final drupal_render over the whole form, it will not re-render the parts already rendered.

Remember that in order for the form to function correctly there are some hidden fields in every form that must be added to the form. Also drupal needs to generate the form tag. Therefore it is my advise, after doing the custom rendering of the parts you want, add a general render of the form. this will reduce the chance of problems with form submission.

Special thanks to Rolf van de Krol, for this tip.

31Aug/090

Sir Richard Francis Burton

Sir Richard Francis Burton: "'The more I study religions the more I am convinced that man never worshipped anything but himself.'"

(Via Quotes of the Day.)

Filed under: fun, humor, thoughts No Comments
29Aug/090

The history of Johnnie Walker in 6min

The first whiskey I ever drank was a Johnnie Walker Red Label. It was horrible. Burned my mouth completely. I was, as can be expected young and knew nothing about whiskey, aside form the name. And that it was apparently "cool" to drink. So I tried. After that one sip I stayed of whiskey for over two years.

The second tim eI tasted whiskey, it was a Johnnie Walker Black label. It was strong, burning, and delightful. I do not know what has changed in those two years or if something changed at all. Maybe if I had tried the black first instead of the red, I would be set right off the start. For the next three years or so I only drank Johnnie Blacks.

As my taste evolved I stated trying more whiskeys. Like most people I started to value the single malts more and more. Eventually completely abandoning the blended sorts, of which Johnnie was my darling. Nowadays I have at home a small collection of singles, out of which I drink a glass almost daily. Whiskey has definitely become my favorite strong drink. Johnnie had a lot to do with it

That is why I was so delighted to see this 6 minute film over the history of Johnnie Walker. Even if you are not a fan of the drink, or the brand, it is worth 6 minutes of your time

Update: Unfortunatley the film was removed due to copy-write violations. quite unfortunate

Filed under: fun, thoughts No Comments
28Aug/090

Opposite directions

You probably heard about justice Scalia of the American supreme court saying executing an innocent man is not unlawful because he was found guilty in a legal trial. New findings which can acquit said innocent man, are, for justice Scalia, no reason not not proceed with what a court has found to be just.
That may sound strange, even scary coming from a supreme court justice. The thing is, I have seen this kind of thinking before from people who give service to society. Sometimes they seem to loose sight of what is actually the grand reason for them being there. They stop seeing their system as a system that gives service to society, but that society is there so obey their wonderful system.

This I believe is exactly what happened to justice Scalia. He lost sight of the reason he is there. To serve society. Executing an innocent man does not do that in any way. Look at it from the other direction, and you can see how he reasons.

One must ask himself if someone who completely lost sight of what its all about could, or should, remain in his position.

For more information on this case read this.

22Aug/090

Bolt’s new world record at the Berlin world championship

Look carefully at Usain as he moves. There is a lot of side movement still present. If he can improve his technique, I believe he might break the 9.5 sec barrier. How wonderful it is to see this man run!