[Xapian-discuss] Key too long: length was 258 bytes, maximum length of a key is BTREE_MAX_KEY_LEN bytes

Olly Betts olly at survex.com
Mon Mar 5 15:46:52 GMT 2007


On Sun, Mar 04, 2007 at 09:28:58PM -0800, Kevin Duraj wrote:
> E: Key too long: length was 258 bytes, maximum length of a key is
> BTREE_MAX_KEY_LEN bytes
> Exception: Key too long: length was 258 bytes, maximum length of a key is
> BTREE_MAX_KEY_LEN bytes

A safe limit is 240 bytes for quartz and flint, unless your terms
can contain zero bytes.  There's a fuller dsecription here:

http://article.gmane.org/gmane.comp.search.xapian.general/3656

> What is the maximum of the characters we can have in:
>      |____ Field : boolean=Q unique=Q weight=5 lower index field

This will attempt to generate a term of indefinite length if the
input data contains a long value.

You can either hash the tail of the term (like omindex does with URLs)
by using the "hash" action (and split the rule into two because you
don't want the field hash-ed, and you don't want the boolean lower-ed):

Field : hash=239 boolean=Q unique=Q
Field : weight=5 lower index field

Alternatively, you can use "truncate=239" instead of "hash=239" to just
discard the end of the term.  If the field contains whitespace,
"truncate" will try not to truncate a "word" but for a url field that
shouldn't be an issue.  There should probably be a simpler version of
"truncate" which doesn't try to be smart with words.

Cheers,
    Olly



More information about the Xapian-discuss mailing list