private Document newDocument(String id,String noteName,Paragraph p){
  Document doc=new Document();
  Field pathField=new StringField(ID_FIELD,id,Field.Store.YES);
  doc.add(pathField);
  doc.add(new StringField("title",noteName,Field.Store.YES));
  if (null != p) {
    doc.add(new TextField(SEARCH_FIELD_TEXT,p.getText(),Field.Store.YES));
    if (p.getTitle() != null) {
      doc.add(new TextField(SEARCH_FIELD_TITLE,p.getTitle(),Field.Store.YES));
    }
    Date date=p.getDateStarted() != null ? p.getDateStarted() : p.getDateCreated();
    doc.add(new LongField("modified",date.getTime(),Field.Store.NO));
  }
 else {
    doc.add(new TextField(SEARCH_FIELD_TEXT,noteName,Field.Store.YES));
  }
  return doc;
}

private Document newDocument ( String id , String noteName , Paragraph p ) { Document doc = new Document ( ) ; Field pathField = new StringField ( ID_FIELD , id , Field . Store . YES ) ; doc . add ( pathField ) ; doc . add ( new StringField ( "title" , noteName , Field . Store . YES ) ) ; if ( null != p ) { doc . add ( new TextField ( SEARCH_FIELD_TEXT , p . getText ( ) , Field . Store . YES ) ) ; if ( p . getTitle ( ) != null ) { doc . add ( new TextField ( SEARCH_FIELD_TITLE , p . getTitle ( ) , Field . Store . YES ) ) ; } Date date = p . getDateStarted ( ) != null ? p . getDateStarted ( ) : p . getDateCreated ( ) ; doc . add ( new LongField ( "modified" , date . getTime ( ) , Field . Store . NO ) ) ; } else { doc . add ( new TextField ( SEARCH_FIELD_TEXT , noteName , Field . Store . YES ) ) ; } return doc ; }
if paragraph is not null , indexes code in the paragraph , otherwise indexes the notebook name .
