[Xapian-discuss] range query for terms

Olly Betts olly at survex.com
Wed Apr 1 06:29:23 BST 2015


On Sun, Mar 29, 2015 at 07:07:25PM +0800, 张吉财 wrote:
> now I am trying to index docs in json format, and came to a question
> about prefix mapping:
> a json doc like:    {"starttime":1111,"endtime":2222}
> considerring mapping prefix to slot number in two ways:
> 1.starttime-->0,endtime--->1
> 2.startime--->hash(starttime), endtime--->hash(endtime), while
> hash(key) is a random int, which may be very sparse but unique, for
> example, using BKDR hash.
> 
> after simple test, both ways seemed to work well. can I use the second
> way(do not have to maintain a mapping), is there performance issues?

It'll add a small overhead to anywhere that has to store the value slot
number.  Also, you have to worry what to do if two fieldnames hash to
the same value...

If you can't have a static mapping, I'd just store the mapping in the
user metadata, then it's there with the database, and any changes are
committed in sync with corresponding changes to the database.

Cheers,
    Olly



More information about the Xapian-discuss mailing list