# Library: Xapian

Xapian provides search capabilities to your program. It supports fulltext search and complex boolean queries. Xapian uses an index, so you have to add data to an index before you can search the index. The index can be on-disk or in-memory; if it’s on-disk, you won’t need to rebuild it every time your program starts.

## Makefile

Use a Makefile like this. You’ll need to have installed Xapian so that xapian-config is executable. This works on Londo.

CXX=g++
CXXFLAGS=-g -Wall -ansi xapian-config --cxxflags xapian-config --libs

all: main

main.o: main.cpp
$(CXX)$(CXXFLAGS) -c main.cpp

main: main.o
$(CXX)$(CXXFLAGS) -o main main.o


## Delve: Tool for inspecting indexes

Xapian comes with a command-line tool called delve. If you created an index on-disk (as opposed to in-memory), you can use this tool to see what’s in there.

You can get some stats:

$delve test.idx UUID = cb27339f-1cfd-49aa-81a3-539909fb0887 number of documents = 31 average document length = 355968 document length lower bound = 72850 document length upper bound = 4749922 highest document id ever used = 31 has positional information = true  And you can list all details for some record (document) number: $ delve -r 1 -d test.idx

Data for record #1:
/Users/JoshuaEckroth/Documents/git/csci221/2014-fall/class-examples/xapian/gutenberg/0ws0610.txt

***The Project Gutenberg's Etext of Shakespeare's First Folio***
**********************The Comedie of Errors*********************

This is our 3rd edition of most of these plays.  See the index.

Copyright laws are changing all over the world, be sure to check