19 package org.sleuthkit.autopsy.keywordsearch;
21 import java.awt.event.ActionEvent;
22 import java.beans.PropertyChangeListener;
23 import java.io.BufferedReader;
24 import java.io.BufferedWriter;
26 import java.io.FileOutputStream;
27 import java.io.IOException;
28 import java.io.InputStream;
29 import java.io.InputStreamReader;
30 import java.io.OutputStream;
31 import java.io.OutputStreamWriter;
32 import java.net.ConnectException;
33 import java.net.ServerSocket;
34 import java.net.SocketException;
35 import java.nio.charset.Charset;
36 import java.nio.file.Path;
37 import java.nio.file.Paths;
38 import java.util.ArrayList;
39 import java.util.Collection;
40 import java.util.List;
41 import java.util.concurrent.locks.ReentrantReadWriteLock;
42 import java.util.logging.Level;
43 import org.openide.util.NbBundle;
45 import javax.swing.AbstractAction;
46 import org.apache.solr.client.solrj.SolrQuery;
47 import org.apache.solr.client.solrj.SolrServerException;
48 import org.apache.solr.client.solrj.request.CoreAdminRequest;
49 import org.apache.solr.client.solrj.response.QueryResponse;
50 import org.apache.solr.client.solrj.response.TermsResponse;
51 import org.apache.solr.client.solrj.SolrRequest;
52 import org.apache.solr.client.solrj.impl.HttpSolrServer;
53 import org.apache.solr.common.util.NamedList;
54 import org.openide.modules.InstalledFileLocator;
55 import org.openide.modules.Places;
60 import org.apache.solr.common.SolrInputDocument;
61 import org.apache.solr.client.solrj.impl.XMLResponseParser;
62 import org.apache.solr.client.solrj.response.CoreAdminResponse;
63 import org.apache.solr.common.SolrDocument;
64 import org.apache.solr.common.SolrDocumentList;
65 import org.apache.solr.common.SolrException;
81 public String toString() {
87 public String toString() {
94 public String toString() {
100 public String toString() {
106 public String toString() {
112 public String toString() {
119 public String toString() {
126 public String toString() {
133 public String toString() {
140 public String toString() {
146 public String toString() {
162 static final String PROPERTIES_FILE = KeywordSearchSettings.MODULE_NAME;
163 static final String PROPERTIES_CURRENT_SERVER_PORT =
"IndexingServerPort";
164 static final String PROPERTIES_CURRENT_STOP_PORT =
"IndexingServerStopPort";
165 private static final String
KEY =
"jjk#09s";
166 static final String DEFAULT_SOLR_SERVER_HOST =
"localhost";
167 static final int DEFAULT_SOLR_SERVER_PORT = 23232;
168 static final int DEFAULT_SOLR_STOP_PORT = 34343;
171 private static final boolean DEBUG =
false;
200 this.localSolrServer =
new HttpSolrServer(
"http://localhost:" + currentSolrServerPort +
"/solr");
201 serverAction =
new ServerAction();
202 solrFolder = InstalledFileLocator.getDefault().locate(
"solr",
Server.class.getPackage().getName(),
false);
205 currentCoreLock =
new ReentrantReadWriteLock(
true);
208 logger.log(Level.INFO,
"Created Server instance");
216 }
catch (NumberFormatException nfe) {
217 logger.log(Level.WARNING,
"Could not decode indexing server port, value was not a valid port number, using the default. ", nfe);
218 currentSolrServerPort = DEFAULT_SOLR_SERVER_PORT;
221 currentSolrServerPort = DEFAULT_SOLR_SERVER_PORT;
228 }
catch (NumberFormatException nfe) {
229 logger.log(Level.WARNING,
"Could not decode indexing server stop port, value was not a valid port number, using default", nfe);
230 currentSolrStopPort = DEFAULT_SOLR_STOP_PORT;
233 currentSolrStopPort = DEFAULT_SOLR_STOP_PORT;
239 public void finalize() throws java.lang.Throwable {
245 serverAction.addPropertyChangeListener(l);
248 int getCurrentSolrServerPort() {
252 int getCurrentSolrStopPort() {
263 volatile boolean doRun =
true;
266 this.stream = stream;
268 final String log = Places.getUserDirectory().getAbsolutePath()
269 + File.separator +
"var" + File.separator +
"log"
270 + File.separator +
"solr.log." + type;
271 File outputFile =
new File(log.concat(
".0"));
272 File first =
new File(log.concat(
".1"));
273 File second =
new File(log.concat(
".2"));
274 if (second.exists()) {
277 if (first.exists()) {
278 first.renameTo(second);
280 if (outputFile.exists()) {
281 outputFile.renameTo(first);
283 outputFile.createNewFile();
285 out =
new FileOutputStream(outputFile);
287 }
catch (Exception ex) {
288 logger.log(Level.WARNING,
"Failed to create solr log file", ex);
299 try (InputStreamReader isr =
new InputStreamReader(stream);
300 BufferedReader br =
new BufferedReader(isr);
302 BufferedWriter bw =
new BufferedWriter(osw);) {
305 while (doRun && (line = br.readLine()) != null) {
314 }
catch (IOException ex) {
315 logger.log(Level.SEVERE,
"Error redirecting Solr output stream", ex);
325 List<Long> getSolrPIDs() {
326 List<Long> pids =
new ArrayList<>();
329 final String pidsQuery =
"Args.4.eq=-DSTOP.KEY=" + KEY +
",Args.6.eq=start.jar";
332 if (pidsArr != null) {
333 for (
int i = 0; i < pidsArr.length; ++i) {
334 pids.add(pidsArr[i]);
346 List<Long> solrPids = getSolrPIDs();
347 for (
long pid : solrPids) {
348 logger.log(Level.INFO,
"Trying to kill old Solr process, PID: {0}", pid);
349 PlatformUtil.killProcess(pid);
358 void start() throws KeywordSearchModuleException, SolrServerNoPortException {
364 if (!isPortAvailable(currentSolrServerPort)) {
368 final List<Long> pids = this.getSolrPIDs();
372 if (pids.isEmpty()) {
373 throw new SolrServerNoPortException(currentSolrServerPort);
382 if (!isPortAvailable(currentSolrServerPort)) {
383 throw new SolrServerNoPortException(currentSolrServerPort);
385 if (!isPortAvailable(currentSolrStopPort)) {
386 throw new SolrServerNoPortException(currentSolrStopPort);
390 logger.log(Level.INFO,
"Starting Solr server from: {0}", solrFolder.getAbsolutePath());
392 if (isPortAvailable(currentSolrServerPort)) {
393 logger.log(Level.INFO,
"Port [{0}] available, starting Solr", currentSolrServerPort);
395 final String MAX_SOLR_MEM_MB_PAR =
"-Xmx" + Integer.toString(MAX_SOLR_MEM_MB) +
"m";
396 List<String> commandLine =
new ArrayList<>();
397 commandLine.add(javaPath);
398 commandLine.add(MAX_SOLR_MEM_MB_PAR);
399 commandLine.add(
"-DSTOP.PORT=" + currentSolrStopPort);
400 commandLine.add(
"-Djetty.port=" + currentSolrServerPort);
401 commandLine.add(
"-DSTOP.KEY=" + KEY);
402 commandLine.add(
"-jar");
403 commandLine.add(
"start.jar");
405 ProcessBuilder solrProcessBuilder =
new ProcessBuilder(commandLine);
406 solrProcessBuilder.directory(solrFolder);
409 Path solrStdoutPath = Paths.get(Places.getUserDirectory().getAbsolutePath(),
"var",
"log",
"solr.log.stdout");
410 solrProcessBuilder.redirectOutput(solrStdoutPath.toFile());
412 Path solrStderrPath = Paths.get(Places.getUserDirectory().getAbsolutePath(),
"var",
"log",
"solr.log.stderr");
413 solrProcessBuilder.redirectError(solrStderrPath.toFile());
415 logger.log(Level.INFO,
"Starting Solr using: {0}", solrProcessBuilder.command());
416 curSolrProcess = solrProcessBuilder.start();
417 logger.log(Level.INFO,
"Finished starting Solr");
422 Thread.sleep(10 * 1000);
423 }
catch (InterruptedException ex) {
424 logger.log(Level.WARNING,
"Timer interrupted");
427 final List<Long> pids = this.getSolrPIDs();
428 logger.log(Level.INFO,
"New Solr process PID: {0}", pids);
429 }
catch (SecurityException ex) {
430 logger.log(Level.SEVERE,
"Could not start Solr process!", ex);
431 throw new KeywordSearchModuleException(
432 NbBundle.getMessage(
this.getClass(),
"Server.start.exception.cantStartSolr.msg"), ex);
433 }
catch (IOException ex) {
434 logger.log(Level.SEVERE,
"Could not start Solr server process!", ex);
435 throw new KeywordSearchModuleException(
436 NbBundle.getMessage(
this.getClass(),
"Server.start.exception.cantStartSolr.msg2"), ex);
446 static boolean isPortAvailable(
int port) {
447 ServerSocket ss = null;
450 ss =
new ServerSocket(port, 0, java.net.Inet4Address.getByName(
"localhost"));
452 ss.setReuseAddress(
true);
457 }
catch (IOException e) {
462 }
catch (IOException e) {
477 void changeSolrServerPort(
int port) {
478 currentSolrServerPort = port;
479 ModuleSettings.setConfigSetting(PROPERTIES_FILE, PROPERTIES_CURRENT_SERVER_PORT, String.valueOf(port));
487 void changeSolrStopPort(
int port) {
488 currentSolrStopPort = port;
489 ModuleSettings.setConfigSetting(PROPERTIES_FILE, PROPERTIES_CURRENT_STOP_PORT, String.valueOf(port));
497 synchronized void stop() {
502 }
catch (KeywordSearchModuleException e) {
503 logger.log(Level.WARNING,
"Failed to close core: ", e);
507 logger.log(Level.INFO,
"Stopping Solr server from: {0}", solrFolder.getAbsolutePath());
510 final String[] SOLR_STOP_CMD = {
518 Process stop = Runtime.getRuntime().exec(SOLR_STOP_CMD, null, solrFolder);
519 logger.log(Level.INFO,
"Waiting for stopping Solr server");
523 if (curSolrProcess != null) {
524 curSolrProcess.destroy();
525 curSolrProcess = null;
528 }
catch (InterruptedException | IOException ex) {
532 if (errorRedirectThread != null) {
533 errorRedirectThread.stopRun();
534 errorRedirectThread = null;
541 logger.log(Level.INFO,
"Finished stopping Solr server");
552 synchronized boolean isRunning() throws KeywordSearchModuleException {
555 if (isPortAvailable(currentSolrServerPort)) {
559 if (curSolrProcess != null && !curSolrProcess.isAlive()) {
566 CoreAdminRequest.getStatus(null, localSolrServer);
568 logger.log(Level.INFO,
"Solr server is running");
569 }
catch (SolrServerException ex) {
571 Throwable cause = ex.getRootCause();
576 if (cause instanceof ConnectException || cause instanceof SocketException) {
577 logger.log(Level.INFO,
"Solr server is not running, cause: {0}", cause.getMessage());
580 throw new KeywordSearchModuleException(
581 NbBundle.getMessage(
this.getClass(),
"Server.isRunning.exception.errCheckSolrRunning.msg"), ex);
583 }
catch (SolrException ex) {
585 logger.log(Level.INFO,
"Solr server is not running", ex);
587 }
catch (IOException ex) {
588 throw new KeywordSearchModuleException(
589 NbBundle.getMessage(
this.getClass(),
"Server.isRunning.exception.errCheckSolrRunning.msg2"), ex);
605 void openCoreForCase(Case theCase)
throws KeywordSearchModuleException {
606 currentCoreLock.writeLock().lock();
609 serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STARTED);
611 currentCoreLock.writeLock().unlock();
620 boolean coreIsOpen() {
621 currentCoreLock.readLock().lock();
623 return (null != currentCore);
625 currentCoreLock.readLock().unlock();
629 void closeCore() throws KeywordSearchModuleException {
630 currentCoreLock.writeLock().lock();
632 if (null != currentCore) {
635 serverAction.putValue(CORE_EVT, CORE_EVT_STATES.STOPPED);
638 currentCoreLock.writeLock().unlock();
642 void addDocument(SolrInputDocument doc)
throws KeywordSearchModuleException {
643 currentCoreLock.readLock().lock();
645 currentCore.addDocument(doc);
647 currentCoreLock.readLock().unlock();
658 String getIndexDirPath(Case theCase) {
659 String indexDir = theCase.getModuleDirectory() + File.separator +
"keywordsearch" + File.separator +
"data";
660 if (uncPathUtilities != null) {
663 if (result == null) {
667 if (result == null) {
685 private Core
openCore(
Case theCase)
throws KeywordSearchModuleException {
692 currentSolrServer =
new HttpSolrServer(
"http://" + host +
":" + port +
"/solr");
694 connectToSolrServer(currentSolrServer);
695 }
catch (SolrServerException | IOException ex) {
696 throw new KeywordSearchModuleException(NbBundle.getMessage(
Server.class,
"Server.connect.exception.msg"), ex);
699 String dataDir = getIndexDirPath(theCase);
700 String coreName = theCase.getTextIndexName();
701 return this.
openCore(coreName.isEmpty() ? DEFAULT_CORE_NAME : coreName,
new File(dataDir), theCase.getCaseType());
710 currentCoreLock.readLock().lock();
712 if (null == currentCore) {
713 throw new NoOpenCoreException();
715 currentCore.commit();
717 currentCoreLock.readLock().unlock();
721 NamedList<Object> request(SolrRequest request)
throws SolrServerException, NoOpenCoreException {
722 currentCoreLock.readLock().lock();
724 if (null == currentCore) {
725 throw new NoOpenCoreException();
727 return currentCore.request(request);
729 currentCoreLock.readLock().unlock();
744 currentCoreLock.readLock().lock();
746 if (null == currentCore) {
747 throw new NoOpenCoreException();
750 return currentCore.queryNumIndexedFiles();
751 }
catch (SolrServerException ex) {
752 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.queryNumIdxFiles.exception.msg"), ex);
755 currentCoreLock.readLock().unlock();
769 currentCoreLock.readLock().lock();
771 if (null == currentCore) {
772 throw new NoOpenCoreException();
775 return currentCore.queryNumIndexedChunks();
776 }
catch (SolrServerException ex) {
777 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.queryNumIdxChunks.exception.msg"), ex);
780 currentCoreLock.readLock().unlock();
794 currentCoreLock.readLock().lock();
796 if (null == currentCore) {
797 throw new NoOpenCoreException();
800 return currentCore.queryNumIndexedDocuments();
801 }
catch (SolrServerException ex) {
802 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.queryNumIdxDocs.exception.msg"), ex);
805 currentCoreLock.readLock().unlock();
819 public boolean queryIsIndexed(
long contentID)
throws KeywordSearchModuleException, NoOpenCoreException {
820 currentCoreLock.readLock().lock();
822 if (null == currentCore) {
823 throw new NoOpenCoreException();
826 return currentCore.queryIsIndexed(contentID);
827 }
catch (SolrServerException ex) {
828 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.queryIsIdxd.exception.msg"), ex);
832 currentCoreLock.readLock().unlock();
847 public int queryNumFileChunks(
long fileID)
throws KeywordSearchModuleException, NoOpenCoreException {
848 currentCoreLock.readLock().lock();
850 if (null == currentCore) {
851 throw new NoOpenCoreException();
854 return currentCore.queryNumFileChunks(fileID);
855 }
catch (SolrServerException ex) {
856 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.queryNumFileChunks.exception.msg"), ex);
859 currentCoreLock.readLock().unlock();
873 public QueryResponse
query(SolrQuery sq)
throws KeywordSearchModuleException, NoOpenCoreException {
874 currentCoreLock.readLock().lock();
876 if (null == currentCore) {
877 throw new NoOpenCoreException();
880 return currentCore.query(sq);
881 }
catch (SolrServerException ex) {
882 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.query.exception.msg", sq.getQuery()), ex);
885 currentCoreLock.readLock().unlock();
900 public QueryResponse
query(SolrQuery sq, SolrRequest.METHOD method) throws KeywordSearchModuleException, NoOpenCoreException {
901 currentCoreLock.readLock().lock();
903 if (null == currentCore) {
904 throw new NoOpenCoreException();
907 return currentCore.query(sq, method);
908 }
catch (SolrServerException ex) {
909 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.query2.exception.msg", sq.getQuery()), ex);
912 currentCoreLock.readLock().unlock();
926 public TermsResponse
queryTerms(SolrQuery sq)
throws KeywordSearchModuleException, NoOpenCoreException {
927 currentCoreLock.readLock().lock();
929 if (null == currentCore) {
930 throw new NoOpenCoreException();
933 return currentCore.queryTerms(sq);
934 }
catch (SolrServerException ex) {
935 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.queryTerms.exception.msg", sq.getQuery()), ex);
938 currentCoreLock.readLock().unlock();
952 currentCoreLock.readLock().lock();
954 if (null == currentCore) {
955 throw new NoOpenCoreException();
957 return currentCore.getSolrContent(content.getId(), 0);
959 currentCoreLock.readLock().unlock();
975 public String
getSolrContent(
final Content content,
int chunkID)
throws NoOpenCoreException {
976 currentCoreLock.readLock().lock();
978 if (null == currentCore) {
979 throw new NoOpenCoreException();
981 return currentCore.getSolrContent(content.getId(), chunkID);
983 currentCoreLock.readLock().unlock();
997 currentCoreLock.readLock().lock();
999 if (null == currentCore) {
1000 throw new NoOpenCoreException();
1002 return currentCore.getSolrContent(objectID, 0);
1004 currentCoreLock.readLock().unlock();
1018 public String
getSolrContent(
final long objectID,
final int chunkID)
throws NoOpenCoreException {
1019 currentCoreLock.readLock().lock();
1021 if (null == currentCore) {
1022 throw new NoOpenCoreException();
1024 return currentCore.getSolrContent(objectID, chunkID);
1026 currentCoreLock.readLock().unlock();
1036 return Ingester.getDefault();
1060 private Core
openCore(String coreName, File dataDir,
CaseType caseType)
throws KeywordSearchModuleException {
1063 if (!dataDir.exists()) {
1068 if (!this.isRunning()) {
1069 logger.log(Level.WARNING,
"Core open requested, but server not yet running");
1070 throw new KeywordSearchModuleException(
1071 NbBundle.getMessage(
this.getClass(),
"Server.openCore.exception.msg"));
1075 CoreAdminRequest.Create createCoreRequest =
new CoreAdminRequest.Create();
1076 createCoreRequest.setDataDir(dataDir.getAbsolutePath());
1077 createCoreRequest.setCoreName(coreName);
1078 createCoreRequest.setConfigSet(
"AutopsyConfig");
1079 createCoreRequest.setIsLoadOnStartup(
false);
1080 createCoreRequest.setIsTransient(
true);
1081 currentSolrServer.request(createCoreRequest);
1085 throw new KeywordSearchModuleException(NbBundle.getMessage(
this.getClass(),
"Server.openCore.exception.noIndexDir.msg"));
1088 return new Core(coreName, caseType);
1090 }
catch (SolrServerException | SolrException | IOException ex) {
1091 throw new KeywordSearchModuleException(
1092 NbBundle.getMessage(
this.getClass(),
"Server.openCore.exception.cantOpen.msg"), ex);
1104 void connectToSolrServer(HttpSolrServer solrServer)
throws SolrServerException, IOException {
1105 CoreAdminRequest.getStatus(null, solrServer);
1120 CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer);
1121 return response.getCoreStatus(coreName).get(
"instanceDir") != null;
1135 CoreAdminResponse response = CoreAdminRequest.getStatus(coreName, currentSolrServer);
1136 Object dataDirPath = response.getCoreStatus(coreName).get(
"dataDir");
1137 if (null != dataDirPath) {
1138 File indexDir = Paths.get((String) dataDirPath,
"index").toFile();
1139 return indexDir.exists();
1148 private final String name;
1154 private final HttpSolrServer solrCore;
1156 private Core(String name,
CaseType caseType) {
1158 this.caseType = caseType;
1160 this.solrCore =
new HttpSolrServer(currentSolrServer.getBaseURL() +
"/" + name);
1165 solrCore.setDefaultMaxConnectionsPerHost(2);
1166 solrCore.setMaxTotalConnections(5);
1167 solrCore.setFollowRedirects(
false);
1170 solrCore.setAllowCompression(
true);
1171 solrCore.setMaxRetries(1);
1172 solrCore.setParser(
new XMLResponseParser());
1176 private QueryResponse
query(SolrQuery sq)
throws SolrServerException {
1177 return solrCore.query(sq);
1180 private NamedList<Object> request(SolrRequest request)
throws SolrServerException {
1182 return solrCore.request(request);
1183 }
catch (IOException e) {
1184 logger.log(Level.WARNING,
"Could not issue Solr request. ", e);
1185 throw new SolrServerException(
1186 NbBundle.getMessage(
this.getClass(),
"Server.request.exception.exception.msg"), e);
1191 private QueryResponse
query(SolrQuery sq, SolrRequest.METHOD method) throws SolrServerException {
1192 return solrCore.query(sq, method);
1195 private TermsResponse
queryTerms(SolrQuery sq)
throws SolrServerException {
1196 QueryResponse qres = solrCore.query(sq);
1197 return qres.getTermsResponse();
1200 private void commit() throws SolrServerException {
1203 solrCore.commit(
true,
true);
1204 }
catch (IOException e) {
1205 logger.log(Level.WARNING,
"Could not commit index. ", e);
1206 throw new SolrServerException(NbBundle.getMessage(
this.getClass(),
"Server.commit.exception.msg"), e);
1210 void addDocument(SolrInputDocument doc)
throws KeywordSearchModuleException {
1213 }
catch (SolrServerException ex) {
1214 logger.log(Level.SEVERE,
"Could not add document to index via update handler: " + doc.getField(
"id"), ex);
1215 throw new KeywordSearchModuleException(
1216 NbBundle.getMessage(
this.getClass(),
"Server.addDoc.exception.msg", doc.getField(
"id")), ex);
1217 }
catch (IOException ex) {
1218 logger.log(Level.SEVERE,
"Could not add document to index via update handler: " + doc.getField(
"id"), ex);
1219 throw new KeywordSearchModuleException(
1220 NbBundle.getMessage(
this.getClass(),
"Server.addDoc.exception.msg2", doc.getField(
"id")), ex);
1233 final SolrQuery q =
new SolrQuery();
1235 String filterQuery = Schema.ID.toString() +
":" + KeywordSearchUtil.escapeLuceneQuery(Long.toString(contentID));
1237 filterQuery = filterQuery + Server.ID_CHUNK_SEP + chunkID;
1239 q.addFilterQuery(filterQuery);
1240 q.setFields(Schema.TEXT.toString());
1243 SolrDocumentList solrDocuments = solrCore.query(q).getResults();
1245 if (!solrDocuments.isEmpty()) {
1246 SolrDocument solrDocument = solrDocuments.get(0);
1247 if (solrDocument != null) {
1248 Collection<Object> fieldValues = solrDocument.getFieldValues(Schema.TEXT.toString());
1249 if (fieldValues.size() == 1)
1251 return fieldValues.toArray(
new String[0])[0];
1255 return fieldValues.toArray(
new String[0])[1];
1259 }
catch (SolrServerException ex) {
1260 logger.log(Level.WARNING,
"Error getting content from Solr", ex);
1267 synchronized void close() throws KeywordSearchModuleException {
1274 CoreAdminRequest.unloadCore(this.name, currentSolrServer);
1275 }
catch (SolrServerException ex) {
1276 throw new KeywordSearchModuleException(
1277 NbBundle.getMessage(
this.getClass(),
"Server.close.exception.msg"), ex);
1278 }
catch (IOException ex) {
1279 throw new KeywordSearchModuleException(
1280 NbBundle.getMessage(
this.getClass(),
"Server.close.exception.msg2"), ex);
1306 SolrQuery q =
new SolrQuery(Server.Schema.ID +
":*" + Server.ID_CHUNK_SEP +
"*");
1308 int numChunks = (int)
query(q).getResults().getNumFound();
1323 SolrQuery q =
new SolrQuery(
"*:*");
1325 return (
int)
query(q).getResults().getNumFound();
1337 private boolean queryIsIndexed(
long contentID)
throws SolrServerException {
1338 String
id = KeywordSearchUtil.escapeLuceneQuery(Long.toString(contentID));
1339 SolrQuery q =
new SolrQuery(
"*:*");
1340 q.addFilterQuery(Server.Schema.ID.toString() +
":" + id);
1343 return (
int)
query(q).getResults().getNumFound() != 0;
1358 String
id = KeywordSearchUtil.escapeLuceneQuery(Long.toString(contentID));
1360 =
new SolrQuery(Server.Schema.ID +
":" +
id + Server.ID_CHUNK_SEP +
"*");
1362 return (
int)
query(q).getResults().getNumFound();
1366 class ServerAction
extends AbstractAction {
1368 private static final long serialVersionUID = 1L;
1371 public void actionPerformed(ActionEvent e) {
1372 logger.log(Level.INFO, e.paramString().trim());
1379 class SolrServerNoPortException
extends SocketException {
1381 private static final long serialVersionUID = 1L;
1386 private final int port;
1388 SolrServerNoPortException(
int port) {
1389 super(NbBundle.getMessage(Server.class,
"Server.solrServerNoPortException.msg", port,
1390 Server.PROPERTIES_CURRENT_SERVER_PORT));
1394 int getPortNumber() {
int queryNumIndexedFiles()
String getSolrContent(final long objectID)
synchronized void rescanDrives()
final ReentrantReadWriteLock currentCoreLock
boolean coreExistsOnServer(String coreName)
int queryNumIndexedChunks()
static final char ID_CHUNK_SEP
final ServerAction serverAction
synchronized String mappedDriveToUNC(String inputPath)
UNCPathUtilities uncPathUtilities
static String getIndexingServerPort()
final HttpSolrServer localSolrServer
static final Logger logger
Core openCore(Case theCase)
void addServerActionListener(PropertyChangeListener l)
static final String HL_ANALYZE_CHARS_UNLIMITED
String getSolrContent(final Content content)
static final long MAX_CONTENT_SIZE
boolean coreIndexFolderExists(String coreName)
HttpSolrServer currentSolrServer
int queryNumIndexedDocuments()
static synchronized void setConfigSetting(String moduleName, String settingName, String settingVal)
static final String CORE_EVT
static final Charset DEFAULT_INDEXED_TEXT_CHARSET
default Charset to index text as
InputStreamPrinterThread errorRedirectThread
static final String DEFAULT_CORE_NAME
QueryResponse query(SolrQuery sq)
static String getConfigSetting(String moduleName, String settingName)
int currentSolrServerPort
TermsResponse queryTerms(SolrQuery sq)
boolean queryIsIndexed(long contentID)
String getSolrContent(final Content content, int chunkID)
String getSolrContent(final long objectID, final int chunkID)
synchronized static Logger getLogger(String name)
Core openCore(String coreName, File dataDir, CaseType caseType)
static final int MAX_SOLR_MEM_MB
static Ingester getIngester()
static String getChunkIdString(long parentID, int childID)
static String getIndexingServerHost()
static boolean settingExists(String moduleName, String settingName)
int queryNumFileChunks(long fileID)
static final boolean DEBUG
QueryResponse query(SolrQuery sq, SolrRequest.METHOD method)