[Xapian-discuss] get the title from the document

jack young young.2004 at yahoo.com
Sat Nov 3 11:36:16 GMT 2012



Dear all,
I am working on a very simple project, in which I wanna get the title from the document.
For instance, this is what I have done so far. 


///////////// code  for building the index file


        # Load content
        content = open(filePath).read()
        # Prepare document
        document = xapian.Document()
        document.set_data(content)
        # Store fileName
        fileName = os.path.basename(filePath)
        document.add_value(xapian_file_name, fileName)
        # Index document
        indexer.set_document(document)
        indexer.index_text(content)                   
        
        #Store indexed content in database
        database.add_document(document)


///////////// code  for searching 

    query = queryParser.parse_query(queryString)    
    enquire.set_query(query)
    matches = enquire.get_mset(offset, limit)
    for match in matches:      
        print 'rank=%s, documentID=%s' % (match.rank, match.docid)
        print match.document.get_data()

//////////// end of the code


Everything works weell. Now my question is how to get the title for the hitted documents.
More precisly, I need the the file name from the hitted document.
For instance, the second document is returnd. Now i also requirt its original file name.

Any thoughts? Thank you in advance.


More information about the Xapian-discuss mailing list