cos-dbupdate.cxx
changeset 6 f0c87fb62b66
parent 4 64b70fc4f30e
--- a/cos-dbupdate.cxx	Sat Feb 12 15:26:27 2011 +0300
+++ b/cos-dbupdate.cxx	Sat Feb 12 17:03:08 2011 +0300
@@ -49,17 +49,22 @@
                 break;
             Xapian::Document newdocument;
             newdocument.set_data(fname);
-            newdocument.add_posting("FILENAME:"+fname, 0);
+            string fnameterm = "FILENAME:"+fname;
+            if (fnameterm.length()>245)
+                fnameterm.erase(245);
+            newdocument.add_posting(fnameterm, 0);
             int i=1;
             while (1) {
                 string term;
                 getline(cin,term);
                 if (cin.eof()||term.empty())
                     break;
+                if (term.length()>245)
+                    term.erase(245);
                 cout << "TERM <" << term << ">" << endl;
                 newdocument.add_posting(term, i++);
             }
-            database.replace_document("FILENAME:"+fname,newdocument);
+            database.replace_document(fnameterm,newdocument);
             cout << "EOFILE <" << fname << ">" << endl;
         }
     } catch(const Xapian::Error &error) {