47 getline(cin,fname); |
47 getline(cin,fname); |
48 if (cin.eof()||fname.empty()) |
48 if (cin.eof()||fname.empty()) |
49 break; |
49 break; |
50 Xapian::Document newdocument; |
50 Xapian::Document newdocument; |
51 newdocument.set_data(fname); |
51 newdocument.set_data(fname); |
52 newdocument.add_posting("FILENAME:"+fname, 0); |
52 string fnameterm = "FILENAME:"+fname; |
|
53 if (fnameterm.length()>245) |
|
54 fnameterm.erase(245); |
|
55 newdocument.add_posting(fnameterm, 0); |
53 int i=1; |
56 int i=1; |
54 while (1) { |
57 while (1) { |
55 string term; |
58 string term; |
56 getline(cin,term); |
59 getline(cin,term); |
57 if (cin.eof()||term.empty()) |
60 if (cin.eof()||term.empty()) |
58 break; |
61 break; |
|
62 if (term.length()>245) |
|
63 term.erase(245); |
59 cout << "TERM <" << term << ">" << endl; |
64 cout << "TERM <" << term << ">" << endl; |
60 newdocument.add_posting(term, i++); |
65 newdocument.add_posting(term, i++); |
61 } |
66 } |
62 database.replace_document("FILENAME:"+fname,newdocument); |
67 database.replace_document(fnameterm,newdocument); |
63 cout << "EOFILE <" << fname << ">" << endl; |
68 cout << "EOFILE <" << fname << ">" << endl; |
64 } |
69 } |
65 } catch(const Xapian::Error &error) { |
70 } catch(const Xapian::Error &error) { |
66 cout << "Exception: " << error.get_msg() << endl; |
71 cout << "Exception: " << error.get_msg() << endl; |
67 } |
72 } |