1

I'm working on a project where I have to index images and their textual metadata. I first thought about Lucene but it's not supporting images. Then I found LIre but it's only working with images and the metadata wouldn't be handled.

Is there an open-source solution to index images and their metadata in a single index?

Otherwise, the only solution I found would be to have two separate indexes and to merge the results. I jut can't figure out how to merge them considering that to each indexed image matches a set of indexed metadata. In this case, I probably need a way to link the set of metadata to the image and reciprocally.

Could you explain to me how I could actually merge the results?

4

1 回答 1

1

我对 LIRE 不是很熟悉,但看起来您将使用DocumentBuilder. 当您从中获取文档时,您可以轻松地向其中添加自己的字段,例如:

 DocumentBuilder builder = /*create your builder*/
 Document doc = builder.createDocument(image, id);
 Field metadata = /*create your metadata field*/
 doc.add(metadata);
 indexWriter.addDocument(doc);

这将允许您利用 LIRE 图像识别并能够单独基于元数据进行搜索。如果您需要能够混合两者,例如通过某些元数据匹配约束过滤的图像识别搜索,您可能需要自己实现。查看 的代码GenericFastImageSearcher,它实际上并没有构建 Lucene 查询,而是迭代图像并进行比较以找到最佳匹配。您应该能够创建自己的findSimilar方法版本,在迭代循环中过滤结果,只需在不满足的地方继续:

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; 
于 2013-10-08T16:15:00.937 回答