I'm not intimately familiar with LIRE, but it looks like you'll create documents using a DocumentBuilder
. When you get a Document back from it, you could easily add your own fields to it, like:
DocumentBuilder builder = /*create your builder*/
Document doc = builder.createDocument(image, id);
Field metadata = /*create your metadata field*/
doc.add(metadata);
indexWriter.addDocument(doc);
This would allow you to leverage LIRE image recognition and be able to search based on metadata separately. If you need to be able to hybridize the two, such as as image recognition search filtered by some metadata match constraint, you'll likely need to implement that yourself. Looking into code of GenericFastImageSearcher
, it doesn't actually construct Lucene queries, but rather iterates images and compares to find the best matches. You should be able to create your own version of the findSimilar
method, filtering results within the iteration loop by simiply continuing where it is not met:
for (int i = 0; i < docs; i++) {
if (reader.hasDeletions() && !liveDocs.get(i)) continue;
d = reader.document(i);
if (!d.getField("metadata").equals(constraint)) continue;