add image_id to Solr schema

This commit is contained in:
adam-m 2013-01-03 10:34:20 -05:00
parent 804991dc3b
commit bc3ccd16a6
4 changed files with 24 additions and 1 deletions

View File

@ -505,6 +505,8 @@
--> -->
<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="id" type="string" indexed="true" stored="true" required="true" />
<!-- use image_id to easily search a specific image only -->
<field name="image_id" type="string" indexed="true" stored="true" required="true" />
<!-- The content field holds the text extracted by SolrCell --> <!-- The content field holds the text extracted by SolrCell -->
<field name="content" type="text_general" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" /> <field name="content" type="text_general" indexed="true" stored="true" termVectors="true" termPositions="true" termOffsets="true" />
<!-- The strings field holds strings extracted from files that SolrCell doesn't support --> <!-- The strings field holds strings extracted from files that SolrCell doesn't support -->

View File

@ -54,6 +54,7 @@ import org.sleuthkit.datamodel.File;
import org.sleuthkit.datamodel.FsContent; import org.sleuthkit.datamodel.FsContent;
import org.sleuthkit.datamodel.LayoutFile; import org.sleuthkit.datamodel.LayoutFile;
import org.sleuthkit.datamodel.ReadContentInputStream; import org.sleuthkit.datamodel.ReadContentInputStream;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* Handles indexing files on a Solr core. * Handles indexing files on a Solr core.
@ -217,6 +218,12 @@ public class Ingester {
private Map<String, String> getCommonFields(AbstractFile af) { private Map<String, String> getCommonFields(AbstractFile af) {
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
params.put(Server.Schema.ID.toString(), Long.toString(af.getId())); params.put(Server.Schema.ID.toString(), Long.toString(af.getId()));
try {
params.put(Server.Schema.IMAGE_ID.toString(), Long.toString(af.getImage().getId()));
} catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Could not get image id to properly index the file " + af.getId());
}
params.put(Server.Schema.FILE_NAME.toString(), af.getName()); params.put(Server.Schema.FILE_NAME.toString(), af.getName());
return params; return params;
} }
@ -239,6 +246,14 @@ public class Ingester {
* @throws org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException * @throws org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException
*/ */
private void ingest(ContentStream cs, Map<String, String> fields, final long size) throws IngesterException { private void ingest(ContentStream cs, Map<String, String> fields, final long size) throws IngesterException {
if (fields.get(Server.Schema.IMAGE_ID.toString()) == null) {
//skip the file, image id unknown
String msg = "Skipping indexing the file, unknown image id, for file: " + cs.getName();
logger.log(Level.SEVERE, msg);
throw new IngesterException(msg);
}
SolrInputDocument updateDoc = new SolrInputDocument(); SolrInputDocument updateDoc = new SolrInputDocument();
for (String key : fields.keySet()) { for (String key : fields.keySet()) {

View File

@ -69,6 +69,12 @@ public class Server {
return "id"; return "id";
} }
}, },
IMAGE_ID {
@Override
public String toString() {
return "image_id";
}
},
CONTENT { CONTENT {
@Override @Override
public String toString() { public String toString() {

View File

@ -56,7 +56,7 @@ public class TermComponentQuery implements KeywordSearchQuery {
private Keyword keywordQuery = null; private Keyword keywordQuery = null;
private KeywordQueryFilter filter = null; private KeywordQueryFilter filter = null;
private String field = null; private String field = null;
private static int MAX_TERMS_RESULTS = 10000; private static int MAX_TERMS_RESULTS = 20000;
private static final boolean DEBUG = (Version.getBuildType() == Version.Type.DEVELOPMENT); private static final boolean DEBUG = (Version.getBuildType() == Version.Type.DEVELOPMENT);