[Xapian-discuss] range query for terms

Olly Betts olly at survex.com
Sun Mar 15 19:36:48 GMT 2015

On Sat, Mar 14, 2015 at 09:25:24PM +0800, 张吉财 wrote:
> then I'd like to ask if it is possible to do a range query on
> terms(like the range query on values), or if it is just a
> wildcard(right truncation) match.

Currently only right truncation is supported.

> the case is searching ip address bettween  “” and “”
> the user want :
> 1.   query "" < ip < ""  gives ""
> 2.   query "*.*.*.10" gives all ip addresses ended with 10.
> how can I achieve this?

You should really consider using a value for this, as such wildcards can
expand to an awful lot of terms - "*.*.*.10" potentially matches 16
million terms.  With a value, there's only one thing to check for every
candidate document.

But if you only actually have a small number of IP addresses and really
want to use terms, you can just iterate allterms from the Database
object and build an OP_SYNONYM query from all the matching terms.  In
1.2.x, that's exactly how OP_WILDCARD is implemented (in master
OP_WILDCARD expansion is delayed until we process the Query tree, which
means we can avoid creating Query objects for every term in the


More information about the Xapian-discuss mailing list