Solr JNDI configuration

January 17, 2011 Leave a comment

As a follow-up on my previous post Solr XML config includes I want to point out another good way to handle environment specific Solr settings: using JNDI. This is not a replacement for XML includes, but in cases where you just need a custom database connection or Solr home dir it might be better suited. Let’s look at two examples.

Read more…

Categories: Solr

Solr test dataset

December 29, 2010 6 comments

For an opensource project I’m working on I need a good Solr test dataset. More info about the project will follow soon, but as a teaser I can already tell it’s Solr and PHP related 😉
The dataset needs to be of a reasonable size (not unrealisticly small, but not huge either) and it should be free to use for anyone, as anyone should be able to test the project.

I’ve worked on quite a lot of Solr projects by now, and have a local environment of most. But obviously I cannot use these indexes for anything other than the projects they belong to, let alone redistribute the data.

For some demos and my post complex solr faceting I’ve used the dataset from the book ‘Solr 1.4 Enterprise Search Server‘, based on MusicBrainz data. But this dataset is not so great for faceting, which is one of the more important items to me. So I decided to look for a better alternative.

Read more…

Categories: Solr

Solr XML config includes

October 30, 2010 Leave a comment

If you ever used Solr in a version controlled project you will probably have run into the same issues as I have: the solr config files contain definitions that you want to have in version control, but they also contain environment specific settings.
You can use the version controlled configs as a distribution version which you edit to suit the environment, but this breaks easy updating to new version.

A good example is the data-config.xml file for the DIH (DataImportHandler). The data mapping described by this config is the same for all environments, but the datasource definition itself (for instance a database connection) differs for dev, test and production environments.
Read more…

Categories: Solr

Stunnel, a practical solution for SSL/TLS

September 10, 2010 Leave a comment

TLS/SSL encryption is generaly a good thing to use, however it can in some cases be hard to implement. Stunnel is a small program that provides SSL/TLS capabilities to clients and/or servers that don’t speak SSL/TLS natively. It basically works like a proxy, transparently adding an encryption layer to the communication layer; or removing it.

There are two main use cases:

  • connecting to an encrypted service using a plaintext client
  • publish an encrypted service, while the actual backend is plaintext

There can be multiple reasons to use Stunnel instead of an implementation directly in the client or server application. You might be using an application that you cannot change. Or it might cost to much time. And Stunnel might in some cases even offer some features that are hard to achieve otherwise.

Read more…

Categories: General, PHP

Integrating Solr with PHP

July 20, 2010 6 comments

Currently there isn’t really a standard way to integrate Solr with PHP. For various projects I have used:

  • manual HTTP requests
  • PHP Solr extension
  • solr-php-client library

They all have their own pros and cons. Read more…

Categories: PHP, Solr Tags: , ,

Cross-domain XHR with Varnish


Cross-domain XHR (AJAX) requests can be an issue. There are workarounds like JSONP but sometimes JSONP is not available, or you need a POST request, or you have other special requirements that require usage of XHR. In that case a webproxy on your own domain is often used to resolve the crossdomain issue.

There are many examples how to solve this inside your application, but when you just need to relay a request you can do this easily with Varnish. That way you don’t need to build anything in your application and you get a high-performance ‘proxy’.

Read more…

Categories: Varnish Tags: , ,

Complex Solr faceting

July 8, 2010 2 comments

When using Solr faceting sooner or later there will be a request for a complex facet, one that at first sight seems impossible using standard Solr faceting. However with some creative use of facets and a small bit of extra logic in your application you can create a very advanced faceting interface. In this example I will explain:

  • How to create multiple facets on the same field by using a key for a unique name and the exclusion of tagged filterqueries for different counts
  • How to use the multiple facet count results to render a single interface element

The best way to explain this is by using a test setup with a good dataset. In the following examples I’ll be using the same test setup as used in the (excellent!) book ‘Solr 1.4 Enterprise Search Server‘, based on MusicBrainz data.
If you have read the book and have the test environment you already know this dataset and you can test the queries yourself, I’ll explain the most important parts of the index for others. But I do assume you have solid understanding of the Solr (faceting) basics for the rest of this example, as I won’t be explaining basic Solr usage.

Read more…

Categories: Solr Tags: