[Xapian-discuss] Newbie problems with searching from Python

James Aylett james-xapian at tartarus.org
Mon Apr 27 18:55:07 BST 2009


On Mon, Apr 27, 2009 at 06:26:24PM +0100, Richard Lewis wrote...

Richard; I can't easily answer your general question about why you
aren't getting the number of results you expect without some idea of
what you're putting into your document. As the FAQ for when you get no
matches at all suggests, try using delve to find out what's actually
being stored in the database for each document.

<http://trac.xapian.org/wiki/FAQ/NoMatches>

(This FAQ perhaps needs rewording to make it obvious that it's useful
when you're getting fewer than expected results as well.)

However this looks weird:

>         # add the document to the database
>         if doc.get_docid() == 0:
>             print '/works/%s has docid of 0' % work['catalogue_no']
>         else:
>             database.replace_document(doc.get_docid(), doc)

Unless I'm misreading the rest of your code, I don't see how this is
going to index anything! get_docid() will return 0 when the document
hasn't been added to a database yet; so you need a
`database.add_document(...)` on that leg of the if, don't you?

I note that you're only indexing some of the text in your HTML
output. This suggests that lots of your HTML template is building
chrome (menus, navigation and so on); it may be easier to index out of
the data store directly rather than converting to HTML and then
indexing that, which strikes me as just an extra step for things to go
wrong or get more confusing in.

J

-- 
  James Aylett

  talktorex.co.uk - xapian.org - uncertaintydivision.org



More information about the Xapian-discuss mailing list