- Timestamp:
- 2009-02-05T14:02:25+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
indexers/trunk/lucene-gs/src/org/greenstone/LuceneWrapper/GS2LuceneIndexer.java
r18444 r18464 294 294 public void startDocument() throws SAXException 295 295 { 296 if (mode_.equals("index")) { 297 println("Starting to index " + file_id_); 298 print("["); 299 } 296 println("Starting to process " + file_id_); 297 print("["); 300 298 } 301 299 302 300 public void endDocument() throws SAXException 303 301 { 304 if (mode_.equals("index")) { 305 println("]"); 306 println("... indexing finished."); 307 } 302 println("]"); 303 println("... processing finished."); 308 304 } 309 305 … … 311 307 throws SAXException 312 308 { 313 if (mode_.equals("index")) { 314 path_ = appendPathLink(path_, qName, atts); 309 path_ = appendPathLink(path_, qName, atts); 310 311 if (qName.equals(doc_tag_level_)) { 312 mode_ = atts.getValue("gs2:mode"); 313 314 pushOnStack(); // start new doc 315 current_node_ = qName; 315 316 316 if (qName.equals(doc_tag_level_)) { 317 pushOnStack(); // start new doc 318 current_node_ = qName; 319 320 String node_id = atts.getValue("gs2:id"); 321 print(" " + qName + ": " + node_id ); 322 current_doc_.add(new Field("nodeID", node_id, Field.Store.YES, Field.Index.UN_TOKENIZED)); 323 324 current_doc_oid_ = atts.getValue("gs2:docOID"); 325 current_doc_.add(new Field("docOID", current_doc_oid_, Field.Store.YES, Field.Index.UN_TOKENIZED)); 326 } 317 String node_id = atts.getValue("gs2:id"); 318 print(" " + qName + ": " + node_id + " (" + mode_ + ")" ); 319 current_doc_.add(new Field("nodeID", node_id, Field.Store.YES, Field.Index.UN_TOKENIZED)); 327 320 328 if (isIndexable(atts)) { 329 indexable_current_node_ = qName; 330 } 331 else { 332 indexable_current_node_ = ""; 333 } 321 current_doc_oid_ = atts.getValue("gs2:docOID"); 322 current_doc_.add(new Field("docOID", current_doc_oid_, Field.Store.YES, Field.Index.UN_TOKENIZED)); 323 } 324 325 if (isIndexable(atts)) { 326 indexable_current_node_ = qName; 327 } 328 else { 329 indexable_current_node_ = ""; 334 330 } 335 331 } … … 350 346 public void endElement(String uri, String localName, String qName) throws SAXException 351 347 { 352 if (mode_.equals("index")) { 348 if (mode_.equals("delete")) { 349 try { 350 deleteDocument(current_doc_oid_); 351 } 352 catch (java.io.IOException e) { 353 e.printStackTrace(); 354 } 355 } 356 else if (mode_.equals("index") || mode_.equals("reindex")) { 353 357 if (qName.equals(indexable_current_node_)) 354 358 { … … 367 371 if (qName.equals(doc_tag_level_)) { 368 372 try { 373 // perhaps this is more efficient if addDocument() 374 // used for "index" and updateDocument() for reindex 369 375 writer_.updateDocument(new Term("docOID", current_doc_oid_), current_doc_, analyzer_); 370 376 } … … 376 382 377 383 path_ = removePathLink(path_); 378 }379 else if (mode_.equals("delete")) {380 if (qName.equals("Delete")) {381 try {382 deleteDocument(current_contents_);383 current_contents_ = "";384 }385 catch (java.io.IOException e) {386 e.printStackTrace();387 }388 }389 384 } 390 385 }
Note:
See TracChangeset
for help on using the changeset viewer.