[Xapian-discuss] Am I looking in the right place

James Aylett james-xapian at tartarus.org
Wed Feb 9 11:47:07 GMT 2005


On Tue, Feb 08, 2005 at 09:27:23PM +0000, John Wards wrote:

> > Take a look at "dbi2omega" in the omega sources directory.
> 
> Oooh my head. If some one has the time could they help me get my head 
> around this..
>
> I have a database called test. the table is called properties. i 
> have the following colums id, address, locationid
> 
> i need to search that database and return the ids.

Run the following command:

$ DBUSER=user DBPASSWORD=pw dbi2omega test properties

this will create a file that looks something like:

----------------------------------------------------------------------
id=1
address=somewhere
locationid=17

id=2
address=somewhere else
locationid=23
----------------------------------------------------------------------

and so on. This is a scriptindex input file; you then need to write an
index file. Something like the following might work:

----------------------------------------------------------------------
id: field unique
address: truncate=50 field=sample
address: index
locationid: boolean=XL lower
----------------------------------------------------------------------

Then run:

$ scriptindex dbpath indexscript inputfile

which will use the index script to generate a Xapian database from the
input file (see docs/scriptindex.txt).

The 'address' column from your database will be indexed, and a sample
generated from the first 50 words. The id will also be available as a
field (in omega, the Xapian document data is used to store named
fields; omegascript gives you access to these for display purposes).

The locationid for each row in the table will be turned into a term of
the form 'XLstuff' where the 'stuff' is the lowercased locationid (I'm
guessing this is a number, so lowercasing doesn't make any
difference). This is as I suggested in my last email, and will allow
you to use the 'B' parameter to the omega CGI to restrict results by
location. (The 'P' parameter will do probabilistic search across the
contents of the 'address' column.)

You'll need to read docs/omegascript.txt to write an omegascript
template, as what you're doing is a little different to the way omega
works out of the box. Short-term, you may have luck using the xml
template - see docs/cgiparams.txt for the FMT parameter to switch
templates.

scriptindex will always stem using the English stemmer. dbi2omega will
only work on the machine that the database is running on, and only
works for mysql (you'll have to modify the DBI:mysql bit to change this).

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org



More information about the Xapian-discuss mailing list