mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
- minor fixes post-refactoring
- improve regex result filtering
This commit is contained in:
parent
ee588d2018
commit
529afce917
@ -177,17 +177,11 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueThing> {
|
||||
//use Lucene query to get files with regular expression match result
|
||||
final String keywordQuery = thing.getName();
|
||||
LuceneQuery filesQuery = new LuceneQuery(keywordQuery);
|
||||
filesQuery.escape();
|
||||
List<FsContent> matches = filesQuery.performQuery();
|
||||
|
||||
//get unique match result files
|
||||
Set<FsContent> uniqueMatches = new TreeSet<FsContent>(new Comparator<FsContent>() {
|
||||
|
||||
@Override
|
||||
public int compare(FsContent fsc1, FsContent fsc2) {
|
||||
return (int) (fsc1.getId() - fsc2.getId());
|
||||
|
||||
}
|
||||
});
|
||||
Set<FsContent> uniqueMatches = new TreeSet<FsContent>();
|
||||
uniqueMatches.addAll(matches);
|
||||
|
||||
int resID = 0;
|
||||
@ -212,8 +206,14 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueThing> {
|
||||
//TODO option in GUI to include approximate matches (faster)
|
||||
boolean matchFound = false;
|
||||
if (contentStr != null) {//if not null, some error getting from Solr, handle it by not filtering out
|
||||
final String keywordQuery = thing.getName();
|
||||
Pattern p = Pattern.compile(keywordQuery, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
//perform java regex to validate match from Solr
|
||||
String origQuery = thingContent.getQuery();
|
||||
|
||||
//escape the regex query because it may contain special characters from the previous match
|
||||
//since it's a match result, we can assume literal pattern
|
||||
origQuery = Pattern.quote(origQuery);
|
||||
Pattern p = Pattern.compile(origQuery, Pattern.CASE_INSENSITIVE | Pattern.DOTALL);
|
||||
|
||||
Matcher m = p.matcher(contentStr);
|
||||
matchFound = m.find();
|
||||
}
|
||||
|
@ -1,10 +1,7 @@
|
||||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.ButtonGroup" name="buttonGroup1">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
@ -22,21 +19,25 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="queryLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="62" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="50" max="-2" attributes="0"/>
|
||||
<Component id="chRegex" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" alignment="0" pref="599" max="32767" attributes="0"/>
|
||||
<Component id="searchButton" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="filesIndexedNameLabel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="filesIndexedValLabel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -30,7 +30,6 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key
|
||||
public KeywordSearchSimpleTopComponent() {
|
||||
initComponents();
|
||||
setName("Simple");
|
||||
buttonGroup1.add(chRegex);
|
||||
searchButton.setEnabled(false);
|
||||
|
||||
putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE);
|
||||
@ -79,18 +78,20 @@ public class KeywordSearchSimpleTopComponent extends TopComponent implements Key
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(queryLabel)
|
||||
.addGap(62, 62, 62)
|
||||
.addGap(50, 50, 50)
|
||||
.addComponent(chRegex))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 599, Short.MAX_VALUE)
|
||||
.addComponent(searchButton)
|
||||
.addComponent(searchButton))
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(filesIndexedNameLabel)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(filesIndexedValLabel)))
|
||||
.addContainerGap())
|
||||
.addComponent(filesIndexedValLabel))))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
@ -66,6 +66,7 @@ public class LuceneQuery implements KeywordSearchQuery {
|
||||
* @param query
|
||||
* @return matches List
|
||||
*/
|
||||
@Override
|
||||
public List<FsContent> performQuery() throws RuntimeException {
|
||||
List<FsContent> matches = new ArrayList<FsContent>();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user