diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties index 30513b4c21..db5ea3f6cb 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Bundle.properties @@ -109,7 +109,7 @@ KeywordSearchIngestModule.init.badInitMsg=Keyword search server was not properly KeywordSearchIngestModule.init.tryStopSolrMsg={0}
Please try stopping old java Solr process (if it exists) and restart the application. KeywordSearchIngestModule.init.noKwInLstMsg=No keywords in keyword list. KeywordSearchIngestModule.init.onlyIdxKwSkipMsg=Only indexing will be done and and keyword search will be skipped (you can still add keyword lists using the Keyword Lists - Add to Ingest). -KeywordSearchIngestModule.doInBackGround.displayName=Keyword Search +KeywordSearchIngestModule.doInBackGround.displayName=Periodic Keyword Search KeywordSearchIngestModule.doInBackGround.finalizeMsg= - Finalizing KeywordSearchIngestModule.doInBackGround.pendingMsg= (Pending) SearchRunner.doInBackGround.cancelMsg= (Cancelling...) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.form b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.form index 19c373e175..bdc494bdf7 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.form +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.form @@ -146,12 +146,12 @@ - + - + @@ -360,4 +360,4 @@ - + \ No newline at end of file diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.java index 596a7f7bf1..2ad073784e 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentPanel.java @@ -130,14 +130,14 @@ class ExtractedContentPanel extends javax.swing.JPanel { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { - MarkupSource source = (MarkupSource) e.getItem(); + TextMarkup source = (TextMarkup) e.getItem(); setMarkup(source); } } }); - setSources(new ArrayList()); + setSources(new ArrayList()); extractedTextPane.setComponentPopupMenu(rightClickMenu); ActionListener actList = new ActionListener() { @@ -205,7 +205,7 @@ class ExtractedContentPanel extends javax.swing.JPanel { extractedTextPane.setPreferredSize(new java.awt.Dimension(700, 400)); jScrollPane1.setViewportView(extractedTextPane); - sourceComboBox.setModel(new javax.swing.DefaultComboBoxModel()); + sourceComboBox.setModel(new javax.swing.DefaultComboBoxModel()); hitLabel.setText(org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class, "ExtractedContentPanel.hitLabel.text")); // NOI18N hitLabel.setToolTipText(org.openide.util.NbBundle.getMessage(ExtractedContentPanel.class, "ExtractedContentPanel.hitLabel.toolTipText")); // NOI18N @@ -358,11 +358,11 @@ class ExtractedContentPanel extends javax.swing.JPanel { private javax.swing.JLabel pagesLabel; private javax.swing.JPopupMenu rightClickMenu; private javax.swing.JMenuItem selectAllMenuItem; - private javax.swing.JComboBox sourceComboBox; + private javax.swing.JComboBox sourceComboBox; // End of variables declaration//GEN-END:variables void refreshCurrentMarkup() { - MarkupSource ms = (MarkupSource) sourceComboBox.getSelectedItem(); + TextMarkup ms = (TextMarkup) sourceComboBox.getSelectedItem(); setMarkup(ms); } @@ -372,11 +372,11 @@ class ExtractedContentPanel extends javax.swing.JPanel { * * @param sources */ - void setSources(List sources) { + void setSources(List sources) { sourceComboBox.removeAllItems(); setPanelText(null, false); - for (MarkupSource ms : sources) { + for (TextMarkup ms : sources) { sourceComboBox.addItem(ms); } @@ -391,8 +391,8 @@ class ExtractedContentPanel extends javax.swing.JPanel { * * @return currently available sources on the panel */ - public List getSources() { - ArrayList sources = new ArrayList<>(); + public List getSources() { + ArrayList sources = new ArrayList<>(); for (int i = 0; i < sourceComboBox.getItemCount(); ++i) { sources.add(sourceComboBox.getItemAt(i)); } @@ -403,8 +403,8 @@ class ExtractedContentPanel extends javax.swing.JPanel { * Get the source selected in the combo box * @return currently selected Source */ - public MarkupSource getSelectedSource() { - return (MarkupSource) sourceComboBox.getSelectedItem(); + public TextMarkup getSelectedSource() { + return (TextMarkup) sourceComboBox.getSelectedItem(); } private void setPanelText(String text, boolean detectDirection) { @@ -565,7 +565,7 @@ class ExtractedContentPanel extends javax.swing.JPanel { * * @param source the selected source */ - void updateControls(MarkupSource source) { + void updateControls(TextMarkup source) { updatePageControls(source); updateSearchControls(source); } @@ -575,7 +575,7 @@ class ExtractedContentPanel extends javax.swing.JPanel { * * @param source selected source */ - void updatePageControls(MarkupSource source) { + void updatePageControls(TextMarkup source) { if (source == null) { enableNextPageControl(false); enablePrevPageControl(false); @@ -614,7 +614,7 @@ class ExtractedContentPanel extends javax.swing.JPanel { * * @param source selected source */ - void updateSearchControls(MarkupSource source) { + void updateSearchControls(TextMarkup source) { //setup search controls if (source != null && source.isSearchable()) { @@ -646,7 +646,7 @@ class ExtractedContentPanel extends javax.swing.JPanel { * * @param source */ - private void scrollToCurrentHit(final MarkupSource source) { + private void scrollToCurrentHit(final TextMarkup source) { if (source == null || !source.isSearchable()) { return; } @@ -666,7 +666,7 @@ class ExtractedContentPanel extends javax.swing.JPanel { * Updates GUI in GUI thread and gets markup in * background thread. To be invoked from GUI thread only. */ - private void setMarkup(MarkupSource source) { + private void setMarkup(TextMarkup source) { setPanelText(NbBundle.getMessage(this.getClass(), "ExtractedContentPanel.setMarkup.panelTxt"), false); new SetMarkupWorker(source).execute(); } @@ -678,11 +678,11 @@ class ExtractedContentPanel extends javax.swing.JPanel { */ private final class SetMarkupWorker extends SwingWorker { - private MarkupSource source; + private TextMarkup source; private String markup; private ProgressHandle progress; - SetMarkupWorker(MarkupSource source) { + SetMarkupWorker(TextMarkup source) { this.source = source; } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java index 8358ec222b..2c5cddd226 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ExtractedContentViewer.java @@ -49,7 +49,7 @@ public class ExtractedContentViewer implements DataContentViewer { private static final Logger logger = Logger.getLogger(ExtractedContentViewer.class.getName()); private ExtractedContentPanel panel; private volatile Node currentNode = null; - private MarkupSource currentSource = null; + private TextMarkup currentSource = null; private final IsDirVisitor isDirVisitor = new IsDirVisitor(); @@ -80,10 +80,11 @@ public class ExtractedContentViewer implements DataContentViewer { * for the text markedup by SOLR and another that just displayed * raw text. */ - final List sources = new ArrayList(); + final List sources = new ArrayList(); - //add additional registered sources for this node - sources.addAll(selectedNode.getLookup().lookupAll(MarkupSource.class)); + // See if the node has any sources attached to it and add them to our + // internal list + sources.addAll(selectedNode.getLookup().lookupAll(TextMarkup.class)); // if it doesn't have any SOLR content, then we won't add more sources @@ -98,9 +99,7 @@ public class ExtractedContentViewer implements DataContentViewer { } // make a new source for the raw content - MarkupSource rawSource = new RawMarkupSource(content); - // @@@ NOTE: We used to do some level of caching between instances when this - // was an inner class. Consider doing so again and save rawSource at the class level + TextMarkup rawSource = new RawTextMarkup(content); currentSource = rawSource; sources.add(rawSource); @@ -118,7 +117,7 @@ public class ExtractedContentViewer implements DataContentViewer { } private void scrollToCurrentHit() { - final MarkupSource source = panel.getSelectedSource(); + final TextMarkup source = panel.getSelectedSource(); if (source == null || !source.isSearchable()) { return; } @@ -157,7 +156,7 @@ public class ExtractedContentViewer implements DataContentViewer { @Override public void resetComponent() { - setPanel(new ArrayList()); + setPanel(new ArrayList()); panel.resetDisplay(); currentNode = null; currentSource = null; @@ -171,7 +170,7 @@ public class ExtractedContentViewer implements DataContentViewer { // see if the node has a MarkupSource object in it // BC @@@ This seems to be added from the upper right search. - Collection sources = node.getLookup().lookupAll(MarkupSource.class); + Collection sources = node.getLookup().lookupAll(TextMarkup.class); if (sources.isEmpty() == false) { return true; } @@ -204,7 +203,7 @@ public class ExtractedContentViewer implements DataContentViewer { * * @param sources */ - private void setPanel(List sources) { + private void setPanel(List sources) { if (panel != null) { panel.setSources(sources); } @@ -266,7 +265,7 @@ public class ExtractedContentViewer implements DataContentViewer { @Override public void actionPerformed(ActionEvent e) { - MarkupSource source = panel.getSelectedSource(); + TextMarkup source = panel.getSelectedSource(); if (source == null) { // reset panel.updateControls(null); @@ -306,7 +305,7 @@ public class ExtractedContentViewer implements DataContentViewer { @Override public void actionPerformed(ActionEvent e) { - MarkupSource source = panel.getSelectedSource(); + TextMarkup source = panel.getSelectedSource(); final boolean hasPreviousItem = source.hasPreviousItem(); final boolean hasPreviousPage = source.hasPreviousPage(); int indexVal = 0; diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedMatchesSource.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedTextMarkup.java similarity index 87% rename from KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedMatchesSource.java rename to KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedTextMarkup.java index b83770da24..88f2691e1b 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedMatchesSource.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/HighlightedTextMarkup.java @@ -37,15 +37,14 @@ import org.sleuthkit.autopsy.keywordsearch.KeywordQueryFilter.FilterType; import org.sleuthkit.datamodel.Content; /** - * Gets extracted content from Solr with the parts that match the query - * highlighted + * Highlights hits for a given document. Knows about pages and such for the content viewer. */ -class HighlightedMatchesSource implements MarkupSource, HighlightLookup { +class HighlightedTextMarkup implements TextMarkup, HighlightLookup { - private static final Logger logger = Logger.getLogger(HighlightedMatchesSource.class.getName()); + private static final Logger logger = Logger.getLogger(HighlightedTextMarkup.class.getName()); private static final String HIGHLIGHT_PRE = ""; //NON-NLS private static final String HIGHLIGHT_POST = ""; //NON-NLS - private static final String ANCHOR_PREFIX = HighlightedMatchesSource.class.getName() + "_"; + private static final String ANCHOR_PREFIX = HighlightedTextMarkup.class.getName() + "_"; private Content content; private String keywordHitQuery; @@ -62,17 +61,17 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup { private List pages; private QueryResults hits = null; //original hits that may get passed in private String originalQuery = null; //or original query if hits are not available - private boolean inited = false; + private boolean isPageInfoLoaded = false; private static final boolean DEBUG = (Version.getBuildType() == Version.Type.DEVELOPMENT); - HighlightedMatchesSource(Content content, String keywordHitQuery, boolean isRegex) { + HighlightedTextMarkup(Content content, String keywordHitQuery, boolean isRegex) { this.content = content; this.keywordHitQuery = keywordHitQuery; this.isRegex = isRegex; this.group = true; - this.hitsPages = new LinkedHashMap(); - this.pages = new ArrayList(); - this.pagesToHits = new HashMap(); + this.hitsPages = new LinkedHashMap<>(); + this.pages = new ArrayList<>(); + this.pagesToHits = new HashMap<>(); this.solrServer = KeywordSearch.getServer(); this.numberPages = 0; @@ -82,23 +81,26 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup { } //when the results are not known and need to requery to get hits - HighlightedMatchesSource(Content content, String solrQuery, boolean isRegex, String originalQuery) { + HighlightedTextMarkup(Content content, String solrQuery, boolean isRegex, String originalQuery) { this(content, solrQuery, isRegex); this.originalQuery = originalQuery; } - HighlightedMatchesSource(Content content, String solrQuery, boolean isRegex, QueryResults hits) { + HighlightedTextMarkup(Content content, String solrQuery, boolean isRegex, QueryResults hits) { this(content, solrQuery, isRegex); this.hits = hits; } - HighlightedMatchesSource(Content content, String solrQuery, boolean isRegex, boolean group, QueryResults hits) { + HighlightedTextMarkup(Content content, String solrQuery, boolean isRegex, boolean group, QueryResults hits) { this(content, solrQuery, isRegex, hits); this.group = group; } - private void init() { - if (inited) { + /** + * The main goal of this method is to figure out which pages / chunks have hits. + */ + private void loadPageInfo() { + if (isPageInfoLoaded) { return; } try { @@ -122,26 +124,22 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup { //extract pages of interest, sorted final long contentId = content.getId(); + /* If this is being called from the artifacts / dir tree, then we + * need to perform the search to get the highlights. + */ if (hits == null) { - //special case, aka in case of dir tree, we don't know which chunks - //reperform search query for the content to get matching chunks info - KeywordSearchQuery chunksQuery = null; - - /** - * Keyword keywordQuery = new Keyword(this.originalQuery, - * !isRegex); if (this.isRegex) { chunksQuery = new - * TermComponentQuery(keywordQuery); } else { chunksQuery = new - * LuceneQuery(keywordQuery); chunksQuery.escape(); } - */ String queryStr = KeywordSearchUtil.escapeLuceneQuery(this.keywordHitQuery); if (isRegex) { //use white-space sep. field to get exact matches only of regex query result queryStr = Server.Schema.CONTENT_WS + ":" + "\"" + queryStr + "\""; } - Keyword keywordQuery = new Keyword(queryStr, false); - chunksQuery = new LuceneQuery(hits.getKeywordList(), keywordQuery); - KeywordQueryFilter contentIdFilter = new KeywordQueryFilter(FilterType.CHUNK, contentId); - chunksQuery.addFilter(contentIdFilter); + + Keyword keywordQuery = new Keyword(queryStr, !isRegex); + List keywords = new ArrayList<>(); + keywords.add(keywordQuery); + KeywordSearchQuery chunksQuery = new LuceneQuery(new KeywordList(keywords), keywordQuery); + + chunksQuery.addFilter(new KeywordQueryFilter(FilterType.CHUNK, contentId)); try { hits = chunksQuery.performQuery(); } catch (NoOpenCoreException ex) { @@ -182,11 +180,11 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup { pages.add(1); pagesToHits.put(1, 0); } - inited = true; + isPageInfoLoaded = true; } //constructor for dummy singleton factory instance for Lookup - private HighlightedMatchesSource() { + private HighlightedTextMarkup() { } @Override @@ -291,7 +289,7 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup { @Override public String getMarkup() { - init(); //inits once + loadPageInfo(); //inits once String highLightField = null; @@ -446,7 +444,7 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup { //this instance does not actually work with Solr public static synchronized HighlightLookup getDefault() { if (instance == null) { - instance = new HighlightedMatchesSource(); + instance = new HighlightedTextMarkup(); } return instance; } @@ -454,6 +452,6 @@ class HighlightedMatchesSource implements MarkupSource, HighlightLookup { @Override //factory method, i.e. invoked on dummy (Lookup) instance public HighlightLookup createInstance(Content c, String keywordHitQuery, boolean isRegex, String originalQuery) { - return new HighlightedMatchesSource(c, keywordHitQuery, isRegex, originalQuery); + return new HighlightedTextMarkup(c, keywordHitQuery, isRegex, originalQuery); } } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchFilterNode.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchFilterNode.java index 5d8a12889e..ea57c13db9 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchFilterNode.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchFilterNode.java @@ -45,7 +45,7 @@ import org.sleuthkit.datamodel.File; */ class KeywordSearchFilterNode extends FilterNode { - KeywordSearchFilterNode(HighlightedMatchesSource highlights, Node original) { + KeywordSearchFilterNode(HighlightedTextMarkup highlights, Node original) { super(original, null, new ProxyLookup(Lookups.singleton(highlights), original.getLookup())); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java index 03347faec7..4870e8efe1 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchQuery.java @@ -18,8 +18,6 @@ */ package org.sleuthkit.autopsy.keywordsearch; -import java.util.Collection; -import org.apache.solr.client.solrj.response.TermsResponse.Term; import org.sleuthkit.datamodel.AbstractFile; /** @@ -28,6 +26,8 @@ import org.sleuthkit.datamodel.AbstractFile; * is created for each query. */ interface KeywordSearchQuery { + + KeywordList getKeywordList(); /** * validate the query pre execution diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java index a9196958ca..cbdbb45ad4 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchResultFactory.java @@ -164,14 +164,8 @@ class KeywordSearchResultFactory extends ChildFactory { return false; } - // Get listname - String listName = ""; - if (queryRequests.size() > 1) { - KeywordList list = XmlKeywordSearchList.getCurrent().getListWithKeyword(keywordSearchQuery.getQueryString()); - if (list != null) { - listName = list.getName(); - } - } + + String listName = queryRequest.getQuery().getKeywordList().getName(); final boolean literal_query = keywordSearchQuery.isLiteral(); @@ -305,7 +299,7 @@ class KeywordSearchResultFactory extends ChildFactory { //wrap in KeywordSearchFilterNode for the markup content, might need to override FilterNode for more customization // store the data in HighlightedMatchesSource so that it can be looked up (in content viewer) - HighlightedMatchesSource highlights = new HighlightedMatchesSource(content, queryStr, !key.getQuery().isLiteral(), false, hits); + HighlightedTextMarkup highlights = new HighlightedTextMarkup(content, queryStr, !key.getQuery().isLiteral(), false, hits); return new KeywordSearchFilterNode(highlights, kvNode); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java index 00b53c1fe8..53efb4e93c 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/LuceneQuery.java @@ -22,7 +22,6 @@ package org.sleuthkit.autopsy.keywordsearch; import java.util.ArrayList; import java.util.Collection; import java.util.Comparator; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -32,10 +31,8 @@ import org.sleuthkit.autopsy.coreutils.Logger; import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.SolrRequest.METHOD; import org.apache.solr.client.solrj.response.QueryResponse; -import org.apache.solr.client.solrj.response.TermsResponse.Term; import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrDocumentList; -import org.openide.util.Exceptions; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.coreutils.EscapeUtil; import org.sleuthkit.autopsy.coreutils.Version; @@ -76,20 +73,15 @@ class LuceneQuery implements KeywordSearchQuery { * @param keywordQuery */ public LuceneQuery(KeywordList keywordList, Keyword keywordQuery) { - this(keywordQuery.getQuery()); this.keywordList = keywordList; this.keywordQuery = keywordQuery; + + // @@@ BC: Long-term, we should try to get rid of this string and use only the + // keyword object. Refactoring did not make its way through this yet. + this.keywordString = keywordQuery.getQuery(); + this.keywordStringEscaped = this.keywordString; } - /** - * Constructor with keyword string to process - * @param queryStr Keyword to search for - */ - public LuceneQuery(String queryStr) { - this.keywordString = queryStr; - this.keywordStringEscaped = queryStr; - isEscaped = false; - } @Override public void addFilter(KeywordQueryFilter filter) { @@ -196,9 +188,9 @@ class LuceneQuery implements KeywordSearchQuery { /** - * Perform the query and return result + * Perform the query and return results of unique files. * @param snippets True if results should have a snippet - * @return list of ContentHit objects + * @return list of ContentHit objects. One per file with hit (ignores multiple hits of the word in the same doc) * @throws NoOpenCoreException */ private List performLuceneQuery(boolean snippets) throws NoOpenCoreException { @@ -215,10 +207,12 @@ class LuceneQuery implements KeywordSearchQuery { try { QueryResponse response = solrServer.query(q, METHOD.POST); SolrDocumentList resultList = response.getResults(); + + // objectId_chunk -> "text" -> List of previews Map>> highlightResponse = response.getHighlighting(); // get the unique set of files with hits - Set solrDocumentsWithMatches = filterDuplicateSolrDocuments(resultList); + Set uniqueSolrDocumentsWithHits = filterDuplicateSolrDocuments(resultList); allMatchesFetched = start + MAX_RESULTS >= resultList.getNumFound(); @@ -230,7 +224,7 @@ class LuceneQuery implements KeywordSearchQuery { return matches; } - for (SolrDocument resultDoc : solrDocumentsWithMatches) { + for (SolrDocument resultDoc : uniqueSolrDocumentsWithHits) { ContentHit contentHit; try { contentHit = createContentHitFromQueryResults(resultDoc, highlightResponse, snippets, sleuthkitCase); @@ -485,6 +479,11 @@ class LuceneQuery implements KeywordSearchQuery { return ""; } } + + @Override + public KeywordList getKeywordList() { + return keywordList; + } /** * Compares SolrDocuments based on their ID's. Two SolrDocuments with @@ -493,6 +492,8 @@ class LuceneQuery implements KeywordSearchQuery { private class SolrDocumentComparatorIgnoresChunkId implements Comparator { @Override public int compare(SolrDocument left, SolrDocument right) { + // ID is in the form of ObjectId_Chunk + String idName = Server.Schema.ID.toString(); String leftID = left.getFieldValue(idName).toString(); int index = leftID.indexOf(Server.ID_CHUNK_SEP); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RawMarkupSource.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RawTextMarkup.java similarity index 97% rename from KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RawMarkupSource.java rename to KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RawTextMarkup.java index cbb21ec3e2..58b381b24b 100755 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RawMarkupSource.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/RawTextMarkup.java @@ -32,18 +32,18 @@ import org.sleuthkit.datamodel.TskData; * Display content with just raw text, no markup * */ -class RawMarkupSource implements MarkupSource { +class RawTextMarkup implements TextMarkup { private int numPages = 0; private int currentPage = 0; private boolean hasChunks = false; - private Content currentContent; + private final Content currentContent; //keep last content cached private String cachedString; private int cachedChunk; - private static final Logger logger = Logger.getLogger(RawMarkupSource.class.getName()); + private static final Logger logger = Logger.getLogger(RawTextMarkup.class.getName()); - RawMarkupSource(Content content) { + RawTextMarkup(Content content) { currentContent = content; initialize(); } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermComponentQuery.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermComponentQuery.java index 202659b5a1..30a2976a9f 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermComponentQuery.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TermComponentQuery.java @@ -49,15 +49,15 @@ class TermComponentQuery implements KeywordSearchQuery { private static final String TERMS_SEARCH_FIELD = Server.Schema.CONTENT_WS.toString(); private static final String TERMS_HANDLER = "/terms"; //NON-NLS private static final int TERMS_TIMEOUT = 90 * 1000; //in ms - private static Logger logger = Logger.getLogger(TermComponentQuery.class.getName()); + private static final Logger logger = Logger.getLogger(TermComponentQuery.class.getName()); private String queryEscaped; - private KeywordList keywordList; - private Keyword keyword; + private final KeywordList keywordList; + private final Keyword keyword; private boolean isEscaped; private List terms; private final List filters = new ArrayList<>(); private String field; - private static int MAX_TERMS_RESULTS = 20000; + private static final int MAX_TERMS_RESULTS = 20000; private static final boolean DEBUG = (Version.getBuildType() == Version.Type.DEVELOPMENT); @@ -220,8 +220,9 @@ class TermComponentQuery implements KeywordSearchQuery { for (Term term : terms) { final String termStr = KeywordSearchUtil.escapeLuceneQuery(term.getTerm()); - - LuceneQuery filesQuery = new LuceneQuery(termStr); + + LuceneQuery filesQuery = new LuceneQuery(keywordList, new Keyword(termStr, true)); + //filesQuery.setField(TERMS_SEARCH_FIELD); for (KeywordQueryFilter filter : filters) { //set filter @@ -252,4 +253,9 @@ class TermComponentQuery implements KeywordSearchQuery { return results; } + + @Override + public KeywordList getKeywordList() { + return keywordList; + } } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/MarkupSource.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextMarkup.java similarity index 99% rename from KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/MarkupSource.java rename to KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextMarkup.java index 8a43906d64..d33d598731 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/MarkupSource.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextMarkup.java @@ -26,7 +26,7 @@ import java.util.LinkedHashMap; * highlight the keyword hits and a version that does not do markup * so that you can simply view the stored text. */ -interface MarkupSource { +interface TextMarkup { /** * @return text optionally marked up with the subsest of HTML that Swing diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/layer.xml b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/layer.xml index ba0c8e1a7b..2932a3ae83 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/layer.xml +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/layer.xml @@ -19,9 +19,9 @@ Services ======================================================= --> - + - +