xapian

Adding fields in xapian c++ library


Hello i am trying xapian c++ library i am basically from java and i used lucene and for now i need xapian i have no other go. so i am using it. In lucene we can use like this

Document doc = new Document();
    doc.add(new Field("title", "stackoverflow", Field.Store.YES, Field.Index.ANALYZED));
    w.addDocument(doc);

So title contains the value .But from this example

Xapian::Document newdocument;
newdocument.set_data(string("stackoverflow");

How to make the same thing in xapian.


Solution

  • Xapian, unlike Lucene, does not constrain how you use document data; it simply allows any binary data to be stored for each document – although this is in some way a missing feature, it also provides more flexibility, meaning that some people could use JSON, some a simple key-value serialization and so on. The downside, of course, is that you have to decide how to serialize your data.

    There is code in Omega which uses a simple key-value serialization that may be helpful. Alternatively, you could look at something like restpose, which gives a higher-level approach to search built on top of Xapian, and is more comparable to Solr.