mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-18 02:27:42 +00:00
fix LuceneQuery for old index schemas
This commit is contained in:
parent
adbc85f744
commit
8fcdee830b
@ -23,8 +23,10 @@ import java.util.Collection;
|
|||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.math.NumberUtils;
|
||||||
import org.apache.solr.client.solrj.SolrQuery;
|
import org.apache.solr.client.solrj.SolrQuery;
|
||||||
import org.apache.solr.client.solrj.SolrRequest.METHOD;
|
import org.apache.solr.client.solrj.SolrRequest.METHOD;
|
||||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||||
@ -221,11 +223,19 @@ class LuceneQuery implements KeywordSearchQuery {
|
|||||||
* will get picked up in the next one. */
|
* will get picked up in the next one. */
|
||||||
final String docId = resultDoc.getFieldValue(Server.Schema.ID.toString()).toString();
|
final String docId = resultDoc.getFieldValue(Server.Schema.ID.toString()).toString();
|
||||||
final Integer chunkSize = (Integer) resultDoc.getFieldValue(Server.Schema.CHUNK_SIZE.toString());
|
final Integer chunkSize = (Integer) resultDoc.getFieldValue(Server.Schema.CHUNK_SIZE.toString());
|
||||||
final String content_str = resultDoc.get(Server.Schema.CONTENT_STR.toString()).toString();
|
String content_str = Objects.toString(resultDoc.get(Server.Schema.CONTENT_STR.toString()), null);
|
||||||
|
|
||||||
int firstOccurence = content_str.indexOf(strippedQueryString);
|
double indexSchemaVersion = NumberUtils.toDouble(KeywordSearch.getServer().getIndexInfo().getSchemaVersion());
|
||||||
if (chunkSize != null && firstOccurence < chunkSize) {
|
if (indexSchemaVersion < 2.0) {
|
||||||
|
//old schema versions don't support chunk_size or the content_str fields, so just accept hits
|
||||||
matches.add(createKeywordtHit(highlightResponse, docId));
|
matches.add(createKeywordtHit(highlightResponse, docId));
|
||||||
|
} else {
|
||||||
|
//for new schemas, check that the hit is before the chunk/window boundary.
|
||||||
|
int firstOccurence = StringUtils.indexOf(content_str, strippedQueryString);
|
||||||
|
//there is no chunksize field for "parent" entries in the index
|
||||||
|
if (chunkSize != null && firstOccurence < chunkSize) {
|
||||||
|
matches.add(createKeywordtHit(highlightResponse, docId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (TskException ex) {
|
} catch (TskException ex) {
|
||||||
return matches;
|
return matches;
|
||||||
|
@ -243,6 +243,7 @@ final class RegexQuery implements KeywordSearchQuery {
|
|||||||
while (hitMatcher.find(offset)) {
|
while (hitMatcher.find(offset)) {
|
||||||
StringBuilder snippet = new StringBuilder();
|
StringBuilder snippet = new StringBuilder();
|
||||||
|
|
||||||
|
//"parent" entries in the index don't have chunk size, so just accept those hits
|
||||||
if (chunkSize != null && hitMatcher.start() >= chunkSize) {
|
if (chunkSize != null && hitMatcher.start() >= chunkSize) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user