Monthly Archives: April 2011

PHP, Xapian and… pointers ?

I just discovered some weird behaviour using Xapian in PHP, and I think it has something to do with pointers. I tried adding two XapianDateValueRangeProcessors as follows :

$qp->add_valuerangeprocessor(new XapianDateValueRangeProcessor(0, 'created:', true, false, 1970));
$qp->add_valuerangeprocessor(new XapianDateValueRangeProcessor(1, 'updated:', true, false, 1970));

But somehow this would break Xapian (I didn’t get any error, this script just stopped completely when parsing the query).
Read more »

Searching date ranges in Xapian and PHP

I have not much experience with Xapian, so the following post might seem trivial to some. But it took me some time to figure this out, so I might as well share my findings. After running some basic examples from the Xapian wiki (which worked out of the box), I needed to be able to search for a range of dates (e.g. date created from – to). After reading the very interesting article on the Xapian Search Architecture, I realised I needed to add a value to the document which contained the date field, opposed to the terms I had been adding. So, while indexing, I added following code :

$doc = new XapianDocument();
// some code ommitted such as adding terms, setting data, ...
$doc->add_value(0, '20110101');
// some more code ommitted such as indexing the text - see examples

The first parameter defines the value slot which you want to use. This is just a number, look at it as an index of the value. You will reuse this index when searching, so it’s best to create a constant for each index regarding readability. Other than this, you create and index the document as explained in the examples.
Read more »

Generating Microsoft Excel files in PHP

I recently tried the pear package for generating excel files (Spreadsheet_Excel_Writer), and the first tests were very positive. I created a very basic class to create new sheets and add new data based upon an array. I will expand this class in the future when needed, e.g. to add images.
Read more »

Using Xapian on OS-X with MAMP

I just compiled and installed Xapian on my MacBook Pro (OS-X 10.6.6) using the instructions from the Xapian installation guide. The first time I compiled Xapian, everything looked ok, but when I tried to run the extension, it appeared to be compiled in the wrong OS Architecture (64-bit, which is the default for gcc aparently, while MAMP and its PHP5 version are compiled in 32-bit). So make sure you add the CXX='g++ -m32' option when you run ./configure. If you are not sure if the extension is built in 32-bit, just check by running

file xapian.so

on the resulting xapian.so file after the build, which should result in something like this :

$ file xapian.so
xapian.so: Mach-O bundle i386

Here’s the sequence for building the Xapian core and bindings (make sure you download and use the latest stable Xapian version) :

curl -O http://oligarchy.co.uk/xapian/1.1.4/xapian-core-1.1.4.tar.gz

curl -O http://oligarchy.co.uk/xapian/1.1.4/xapian-bindings-1.1.4.tar.gz

tar xvzf xapian-core-1.1.4.tar.gz

tar xvzf xapian-bindings-1.1.4.tar.gz

cd xapian-core-1.1.4

./configure CXX='g++ -m32'

make

sudo make install

cd ..

cd xapian-bindings-1.1.4

./configure CXX='g++ -m32' --with-php

make

sudo make install

cd ..

rm xapian-core-1.1.4.tar.gz

rm xapian-bindings-1.1.4.tar.gz

This will install the PHP bindings with the default OS-X Apache and PHP version, but as I am using MAMP for my development, I will need to perform some extra steps.
Read more »

Logorama movie

Here’s another very nice 3D movie I found on the net :

http://www.baekdal.com/design/logorama-pulp-fiction-for-brands

But I must warn you, there might be some hidden publicity in the movie…

Galapagos

Some pictures we took on our honeymoon in Galapagos.

Read more »

Order tracking @ foto.com

I just ordered a photobook at foto.com (Belgium), and I was pleasantly surprised with the order tracking page :

I’m just disappointed they don’t show the names of the people working on my product, so I can send them a thank-you-note ;-)