Ciaccio, Mauro
2013-Nov-11 18:07 UTC
[Xapian-discuss] Saving multiple fields within one Xapian document
Hi, I am experimenting with substituting a SQL Server Full Text Catalogue search with Xapian. I am not sure what is the correct / best way to build the Xapian index. In my code I have tried two approaches using (var db = SearchManager.OpenWriteDatabase()) using (var indexer = new TermGenerator()) using (var stemmer = new Stem("english")) using (var doc = new Document()) { //doc.AddValue(0, item.RowID.ToString()); //doc.AddValue(1, item.Description); //doc.AddValue(2, item.ItemCode); doc.SetData(string.Format("{0}_{1}_{2}", item.RowID.ToString(), item.Description, item.ItemCode)); indexer.SetDocument(doc); indexer.SetStemmer(stemmer); indexer.IndexText(item.Description); indexer.IndexText(item.ItemCode); db.AddDocument(doc); } The SetData approach is the only one that I can get to work. I'd appreciate any suggestions. Thanks CONFIDENTIALITY NOTICE - This e-mail transmission, and any documents, files or previous e-mail messages attached to it, may contain information that is confidential. If you are not the intended recipient, or a person responsible for delivering it to the intended recipient, you are hereby notified that you must not read this transmission and that any disclosure, copying, printing, distribution or use of any of the information contained in or attached to this transmission is STRICTLY PROHIBITED. If you have received this transmission in error, please immediately notify the sender by telephone or return e-mail and delete the original transmission and its attachments without reading or saving in any manner.
James Aylett
2013-Nov-11 18:48 UTC
[Xapian-discuss] Saving multiple fields within one Xapian document
On 11 Nov 2013, at 18:07, "Ciaccio, Mauro" <Mauro.Ciaccio at ghxeurope.com> wrote:> I am experimenting with substituting a SQL Server Full Text Catalogue search with Xapian. > > I am not sure what is the correct / best way to build the Xapian index. In my code I have tried two approaches[snip] So the two you've tried are: * using document data * using document values Usually, document data is what you want here. There's an example (in python, but should be readable to all) at <http://getting-started-with-xapian.readthedocs.org/en/latest/practical_example/indexing/writing_the_code.html> which serialises a bunch of different pieces of information using JSON, and stores that in the document data. You can read more about document data & document values here: <http://getting-started-with-xapian.readthedocs.org/en/latest/concepts/indexing/index.html> ? document values are intended for use during search, while document data is generally used when displaying search results, but not when evaluating every possible matching document during a search. (Which roughly translates as: avoid storing document values that you aren't going to use.) Hopefully the various worked examples in that getting started guide are helpful in understanding how to tackle various problems with Xapian. Best, James -- James Aylett, occasional trouble-maker xapian.org