View Javadoc

1   package org.kuali.ole.docstore.indexer.solr;
2   
3   import org.apache.solr.client.solrj.SolrServerException;
4   import org.apache.solr.client.solrj.response.QueryResponse;
5   import org.apache.solr.common.SolrDocument;
6   import org.apache.solr.common.SolrInputDocument;
7   import org.kuali.ole.docstore.model.xmlpojo.ingest.RequestDocument;
8   
9   import java.io.File;
10  import java.io.IOException;
11  import java.net.MalformedURLException;
12  import java.util.List;
13  
14  /**
15   * Created with IntelliJ IDEA.
16   * User: mjagan
17   * Date: 7/2/13
18   * Time: 4:17 PM
19   * To change this template use File | Settings | File Templates.
20   */
21  public interface IndexerService {
22  
23      public static final String SUCCESS = "success";
24      public static final String FAILURE = "failure";
25      public static final String UUID_FILE_NAME_SUFFIX = "_UUID_.xml";
26  
27      public static final String ID_FIELD_PREFIX = "id_disc_";
28      public static final int BATCH_SIZE = 10000;
29      public static final String BIBLIOGRAPHIC = "bibliographic";
30      public static final String DOC_TYPE = "DocType";
31      public static final String DOC_FORMAT = "DocFormat";
32      public static final String HOLDINGS_IDENTIFIER = "holdingsIdentifier";
33      public static final String ITEM_IDENTIFIER = "itemIdentifier";
34      public static final String INSTANCE = "instance";
35  
36  
37      /**
38       * Deletes the documents (if existing) with the Ids specified in the given uuidList.
39       *
40       * @param docCategory
41       * @param uuidList
42       * @return SUCCESS or FAILURE (with error id if any)
43       */
44      public String deleteDocuments(String docCategory, List<String> uuidList)
45              throws MalformedURLException, SolrServerException;
46  
47      /**
48       * Deletes the document (if existing) with the given uuid.
49       *
50       * @param docCategory
51       * @param uuid
52       * @return SUCCESS or FAILURE (with error id if any)
53       */
54      public String deleteDocument(String docCategory, String uuid);
55  
56      //public String addDocuments(String docCategory, String docType, String docFormat, String docContent) throws Exception;
57  
58      /**
59       * Indexes the documents from the xml files in the given fileDir.
60       * Uses solrj API (SolrInputDocuments) instead of DIH (DataImportHandler).
61       * The name of xml files should be of the form "{uuid}_UUID_.xml",
62       * where {uuid} is the "id" field value for the document in the xml file.
63       * Otherwise a random uuid will be assigned for the document.
64       *
65       * @param docCategory
66       * @param docType
67       * @param docFormat
68       * @param dataDir
69       * @return SUCCESS ("success-N" where N is num of documents processed); FAILURE (with error id if any).
70       */
71      public String indexDocumentsFromDirBySolrDoc(String docCategory, String docType, String docFormat, String dataDir);
72  
73      public String indexDocumentsFromStringBySolrDoc(String docCategory, String docType, String docFormat, String data)
74              throws IOException;
75  
76      public String indexDocumentsFromFileBySolrDoc(String docCategory, String docType, String docFormat,
77                                                    String filePath);
78  
79      public String indexDocumentsFromFiles(String docCategory, String docType, String docFormat, List<File> fileList);
80  
81      public String indexDocuments(List<RequestDocument> requestDocuments);
82  
83      public String indexDocuments(List<RequestDocument> requestDocuments, boolean commit);
84  
85      public String indexDocument(RequestDocument requestDocument);
86  
87      public String indexDocument(RequestDocument requestDocument, boolean commit);
88  
89      public String indexSolrDocuments(List<SolrInputDocument> solrDocs);
90  
91      public void commit() throws Exception;
92  
93      public void rollback() throws Exception;
94  
95      /**
96       * Method to bulk Index Documents
97       *
98       * @param requestDocuments
99       * @return
100      */
101     public String bulkIndexDocuments(List<RequestDocument> requestDocuments, boolean isCommit);
102 
103     public List<SolrDocument> getSolrDocumentBySolrId(String uniqueId);
104 
105 //    public List<SolrDocument> getSolrDocumentBySolrId(String uniqueId,String docType);
106 
107     public List<SolrDocument> getSolrDocument(String fieldName, String fieldValue);
108 
109     public QueryResponse searchBibRecord(String docCat, String docType, String docFormat, String fieldName,
110                                          String fieldValue, String fieldList);
111 
112     public void cleanupDiscoveryData() throws IOException, SolrServerException;
113 
114     public String bind(List<RequestDocument> requestDocument) throws Exception, IOException;
115 
116     public String bind(RequestDocument requestDocument) throws Exception;
117 
118     public String unbind(List<RequestDocument> requestDocuments) throws Exception;
119 
120     public void transferInstances(List<RequestDocument> requestDocuments) throws Exception;
121 
122     public void transferItems(List<RequestDocument> requestDocuments) throws Exception;
123 
124     public String delete(List<RequestDocument> requestDocuments) throws Exception;
125 
126     public String delete(RequestDocument requestDocument) throws SolrServerException, Exception;
127 
128     public String buildUuid();
129 }