mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-12 16:06:15 +00:00
Fix to make .* regex queries more feasible (no need to send term containing * char to Solr)
This commit is contained in:
parent
6afe67afa0
commit
f67715bc59
@ -184,10 +184,15 @@ public class KeywordSearchResultFactory extends ChildFactory<KeyValueThing> {
|
||||
//the query is executed later on demand
|
||||
StringBuilder highlightQuery = new StringBuilder();
|
||||
Collection<Term> terms = tcq.getTerms();
|
||||
final int lastTerm = terms.size() -1;
|
||||
int curTerm = 0;
|
||||
for (Term term : terms) {
|
||||
final String termS = KeywordSearchUtil.escapeLuceneQuery(term.getTerm(), true);
|
||||
highlightQuery.append(termS);
|
||||
highlightQuery.append(" ");
|
||||
if (! termS.contains("*")) {
|
||||
highlightQuery.append(termS);
|
||||
if (lastTerm != curTerm)
|
||||
highlightQuery.append(" ");
|
||||
}
|
||||
}
|
||||
//String highlightQueryEscaped = KeywordSearchUtil.escapeLuceneQuery(highlightQuery.toString());
|
||||
String highlightQueryEscaped = highlightQuery.toString();
|
||||
|
@ -165,21 +165,23 @@ public class TermComponentQuery implements KeywordSearchQuery {
|
||||
//it's much more efficient and should yield the same file IDs as per match queries
|
||||
//requires http POST query method due to potentially large query size
|
||||
StringBuilder filesQueryB = new StringBuilder();
|
||||
final int lastTerm = terms.size() -1;
|
||||
final int lastTerm = terms.size() - 1;
|
||||
int curTerm = 0;
|
||||
for (Term term : terms) {
|
||||
//final String termS = KeywordSearchUtil.escapeLuceneQuery(term.getTerm(), true);
|
||||
final String termS = term.getTerm();
|
||||
filesQueryB.append(termS);
|
||||
if (curTerm != lastTerm)
|
||||
filesQueryB.append(" ");
|
||||
if (!termS.contains("*")) {
|
||||
filesQueryB.append(termS);
|
||||
if (curTerm != lastTerm) {
|
||||
filesQueryB.append(" ");
|
||||
}
|
||||
}
|
||||
++curTerm;
|
||||
}
|
||||
List<FsContent> uniqueMatches = new ArrayList<FsContent>();
|
||||
|
||||
if (! terms.isEmpty()) {
|
||||
if (!terms.isEmpty()) {
|
||||
LuceneQuery filesQuery = new LuceneQuery(filesQueryB.toString());
|
||||
filesQuery.escape(); //TODO escaping invididual terms above instead could make a difference to Solr
|
||||
filesQuery.escape();
|
||||
try {
|
||||
uniqueMatches = filesQuery.performQuery();
|
||||
} catch (RuntimeException e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user