Xapian 初体验之 hello xapian

文件夹结构:

~/helloxapian

~/helloxapian/indexfiles.py

~/helloxapian/search.py

~/helloxapian/test

~/helloxapian/test/hello.txt

~/helloxapian/test/world.txt

~/helloxapian/test/abc.txt

hello.txt文件内容:

world.txt文件内容:

abc.txt文件内容:

indexfiles.py文件:

#!/usr/bin/env python

#coding=utf-8

import sys

import xapian

import string

from os import listdir

import re

rex=re.compile('[a-zA-Z0-9]+') #给英文内容进行简单的分词,暂时不涉及中文

MAX_TERM_LENGTH = 64 #设置一个关键词的最大长度

DBPATH='indexdb' #索引文件目录

if len(sys.argv) < 2:

try:

except Exception, e: