0

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.

Ramesh
  • 2,295
  • 5
  • 35
  • 64

1 Answers1

0

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.

James Aylett
  • 3,332
  • 19
  • 20
  • Okey i understand that xapian uses do not use the fields like lucene.Then how the sorting works say i have a field price in lucene and i can sort it but how can i do that in xapian – Ramesh Oct 01 '12 at 20:09
  • i think this should work Xapian::Document doc; doc.add_value(0, Xapian::sortable_serialise(price)); – Ramesh Oct 01 '12 at 20:11
  • Yep, then you can use that value as a sort key when running queries. – James Aylett Nov 03 '12 at 16:28