cos-dbupdate.cxx
changeset 3 38269b62d856
parent 0 56281d90869c
child 4 64b70fc4f30e
equal deleted inserted replaced
2:c9188930a16f 3:38269b62d856
    45             getline(cin,fname);
    45             getline(cin,fname);
    46             if (cin.eof()||fname.empty())
    46             if (cin.eof()||fname.empty())
    47                 break;
    47                 break;
    48             Xapian::Document newdocument;
    48             Xapian::Document newdocument;
    49             newdocument.set_data(fname);
    49             newdocument.set_data(fname);
    50             newdocument.add_posting("FILENAME="+fname, 0);
    50             newdocument.add_posting("FILENAME:"+fname, 0);
    51             int i=1;
    51             int i=1;
    52             while (1) {
    52             while (1) {
    53                 string term;
    53                 string term;
    54                 getline(cin,term);
    54                 getline(cin,term);
    55                 if (cin.eof()||term.empty())
    55                 if (cin.eof()||term.empty())
    56                     break;
    56                     break;
    57                 cout << "TERM <" << term << ">" << endl;
    57                 cout << "TERM <" << term << ">" << endl;
    58                 newdocument.add_posting(term, i++);
    58                 newdocument.add_posting(term, i++);
    59             }
    59             }
    60             database.replace_document("FILENAME="+fname,newdocument);
    60             database.replace_document("FILENAME:"+fname,newdocument);
    61             cout << "EOFILE <" << fname << ">" << endl;
    61             cout << "EOFILE <" << fname << ">" << endl;
    62         }
    62         }
    63     } catch(const Xapian::Error &error) {
    63     } catch(const Xapian::Error &error) {
    64         cout << "Exception: "  << error.get_msg() << endl;
    64         cout << "Exception: "  << error.get_msg() << endl;
    65     }
    65     }