[Xapian-discuss] Q prefix / Unique ID not being found

Sig Lange sig.lange at gmail.com
Fri Mar 11 17:40:58 GMT 2005


On Fri, 11 Mar 2005 16:36:53 +0000, James Aylett
<james-xapian at tartarus.org> wrote:
> On Fri, Mar 11, 2005 at 10:39:53AM -0500, Sig Lange wrote:
> 
> > -- the /bin/read (hacked down for brevity)--
> > sys.stderr = sys.stdout
> > FieldStore = cgi.FieldStorage()
> > print "Content-Type: text/html"
> > print
> > xapdb = xapian.Database("..")
> >
> > enquire = xapian.Enquire(xapdb)
> > stemmer = xapian.Stem("english")
> >
> > qp = xapian.QueryParser()
> > # i do have other prefixes but only Q is important to my example
> > qp.set_prefix("id", "Q")
> >
> > id = FieldStore.getvalue("id", "")
> > q = "id:" + id
> >
> > query = qp.parse_query(q)
> >
> > enquire.set_query(query)
> > matches = enquire.get_mset(0, 1)
> >
> > if  matches.get_matches_upper_bound() == 0:
> >    print "ERROR: Oops, unable to find a message %s" % (id)
> >    sys.exit(0)
> >
> > match = iter(matches).next()
> >
> > print "ID %i %i%% [%s]" % \
> > (match[xapian.MSET_DID], match[xapian.MSET_PERCENT],
> > match[xapian.MSET_DOCUMENT].get_data())
> >
> > -- the /bin/read --
> 
> How about, instead of your QueryParser bit ...:
> 
> ----------------------------------------------------------------------
> id = FieldStore.getvalue("id", "")
> query = xapian.Query(xapian.Query.OP_OR, ["Q%s" % str(id)])
> enquire.set_query(query)
> ----------------------------------------------------------------------
I tried this method and didn't seem to run into any missing documents!
interesting enough. Perhaps the query parser is interpreting some of
my data in the UID as something else? This will work for getting the
document I would like however to enter a uid In the search box.  being
able to enter id:76ea421cdd3e080e13610033f19bd09c88df610d to retrieve
that document. Perhaps there is a bug in the query parser?
> 
> since you really don't need to bother about the query parser for this
> kind of work.

> 
> I'm pretty sure that if a document never got into the database, its
> Q-term won't have done either. So if you're getting the id terms to
> look for out of the Xapian database, you should be able to find the
> documents as well.
I am pretty positive the document made it into the database, atleast
.add_document() was returned valid docids.
> 
> You could try getting the posting list from the term, and print the
> docid for each Q-term you find, then interrogate the database directly
> for those documents, if you're worried there's an inconsistency
> between the different tables.
No need now, your method of retrieving the document ensures that each
document is infact in the database, Q term intact.

I'll try looking into the source of the queryParser and see if I can
figure anything out. Any additional information of why passing
id:<uid> to teh query parser would not work would be great!

Thanks
> 
> J
> 
> --
> /--------------------------------------------------------------------------\
>   James Aylett                                                  xapian.org
>   james at tartarus.org                               uncertaintydivision.org
>



More information about the Xapian-discuss mailing list