lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On Aug 25, 2008, at 11:17 AM, Robert Raschke wrote:

On Mon, Aug 25, 2008 at 9:43 AM, Yuri Takhteyev <yuri@sims.berkeley.edu > wrote:
If
there were a good search system with Lua bindings, integrating it into
Sputnik would be the next item on my todo list.  Unfortunately, there
isn't any that I know of and I can't afford to start working on one
myself at the moment...

Xapian (http://xapian.org/) comes with a bunch of different language
bindings. That would be a good place to start. And the Xapian Omega is
a pretty good introduction on how to make a web search (and could be
used behind the scenes without having a direct Lua binding).

Alternatively, SQLite's FTS3 module (aka Full Text Search) works rather nicely as well.

The next release of Nanoki provides full text search using SQLite's FTS3:

http://svr225.stepx.com:3388/search?q=sputnik
http://svr225.stepx.com:3388/search?q=lua
http://svr225.stepx.com:3388/a

The API itself is rather straightforward as well and can be accessed directly from LuaSQL:

-- create a virtual table

create virtual table document using fts3
(
    name,
    content,
    tokenize porter
)


-- insert stuff into it

insert or ignore into document( name, content ) values( %s, %s )

-- query it

select      document.name as name,
            snippet( document, '<i>', '</i>', '…' ) as extract
from        [v:partition].document
where       document.content match %s
order by    1
limit       %s

Cheers,

--
PA.
http://alt.textdrive.com/nanoki/