Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUDs ➜ General ➜ Suggest use of SQLite3 FTS3 database for help queries

Suggest use of SQLite3 FTS3 database for help queries

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Nick Gammon   Australia  (23,165 posts)  Bio   Forum Administrator
Date Mon 08 Feb 2010 03:48 AM (UTC)

Amended on Mon 08 Feb 2010 03:49 AM (UTC) by Nick Gammon

Message
I have been playing with SQLite3 recently, and in particular the FTS3 extension (Full Text Search).

http://www.sqlite.org/fts3.html

MUD implementers may wish to take a look at this, as it provides an easy way of providing "Google-like" searches of any text.

Your first step would be to create a database with a "virtual table" of type "fts3" and populate it in the usual way by using "INSERT INTO" statements. For example, you might populate the database with the help name being one field, and the help contents being another.

For example, from Smaug:


Level = 1 

Name = ABATTOIR

Contents = 

Once a monument to health and sanity, the Abbot Hill Asylum has been
corrupted over the years and now lies in a state of irrepairable decay.
Located on a large isle in the Blood Sea, the insane and dying were once
brought there to be healed and cared for. Unfortunately, it seems that the
priests in care of these decrepit souls were infected by the same lack of
sanity they were attempting to cure. What was once a place of peace and
salvation has become a haven of the damned, ruled by chaos unbridled.


Now you can let your players do a "full text" search by doing something like:


SEARCH monument AND sanity
SEARCH "attempt to cure" NEAR peace
SEARCH sanity AND NOT spell
SEARCH train OR learn


The full text search is fast, because the entire text is pre-indexed into a B-tree, but you can use all the extra operators such as AND, OR, NEAR, NOT to narrow down your searches.

The server could simply open the database at startup time, and have it ready for a quick query whenever the player needs some help.

The web page above quotes speeds of 0.03 seconds to scan 517430 documents for a single word, so I think for a normal MUD's help files, the overhead would be absolutely minimal.

You might also index things like area descriptions, so if a player is trying to find "the area with a swamp in it, and some rats" a simple search could reveal it.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


5,972 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.