How to match partial queries (or: how to pass flags to djapian)

77 views
Skip to first unread message

BozeWolf

unread,
Feb 12, 2010, 9:32:36 AM2/12/10
to Djapian Users
Hi all,

for a project I would like to do partial matches.
Fir example, I have this list of names:
BozeWolf
Roel Kramer
SneeuwWitje

q = Roe
results = comp.search(q)#.prefetch()
results = results.flags(xapian.QueryParser.FLAG_PARTIAL)

This matches Roel kramer, but if I do
q = oel
it matches nothing.

q = e
matches everything

Is this the correct way to apply queryparser flags to djapian? How do
get q = oel to match Roel? A bit more flags documentation would be
usefull. Thanks in advance.

Roel Kramer

Alex Koshelev

unread,
Feb 21, 2010, 7:25:39 AM2/21/10
to djapia...@googlegroups.com
Hi, Roel!

The result you've seen is Xapian feature. Partial search only matches
from beginning of the word -- that's why you can search 'Roe' but
cannot 'oel'. And one char search term like 'e' is also the specific
Xapian behavior allows to match distinct chars.

So it is not the Djapian issue.

---
Alex Koshelev

> --
> You received this message because you are subscribed to the Google Groups "Djapian Users" group.
> To post to this group, send email to djapia...@googlegroups.com.
> To unsubscribe from this group, send email to djapian-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/djapian-users?hl=en.
>
>

Roel Kramer

unread,
Feb 22, 2010, 6:57:39 AM2/22/10
to djapia...@googlegroups.com
Thanks for the answer,

I understand the searching flags are features of xapian, but I still do
not understand where to apply these search flags. In the message below i
did it like so:

1: q = Roe
2: results = comp.search(q)#.prefetch()
3: results = results.flags(xapian.QueryParser.FLAG_PARTIAL)

Is it correct to pass flags to results on line 3? It seems to work, but
it looks a bit strange to apply flags to search results.

thanks,

Roel

Alex Koshelev

unread,
Feb 22, 2010, 9:10:29 AM2/22/10
to djapia...@googlegroups.com
Yep, it is the correct usage. The ResultSet objects are lazy (just
like QuerySets in Django) and only evaluated when you iterate over it.
Before that you can customize search by adding flags, filter and so
on.

---
Alex Koshelev

umc

unread,
Jul 23, 2012, 3:31:45 PM7/23/12
to djapia...@googlegroups.com
I've posted a similar question in the AND/OR thread, but I'd like to reiterate: why isn't it possible to search for 'oel' and return 'Roel' ? It seems like a valid request. Not even with some flag like PARTIAL, WILDCARD ? It's a really important issue for me.


luni, 22 februarie 2010, 16:10:29 UTC+2, Alexander Koshelev a scris:
Yep, it is the correct usage. The ResultSet objects are lazy (just
like QuerySets in Django) and only evaluated when you iterate over it.
Before that you can customize search by adding flags, filter and so
on.

---
Alex Koshelev

> Thanks for the answer,

Reply all
Reply to author
Forward
0 new messages