我对Lucene没有多少经验,但我需要完成一项研究。我想使用基于本体的Lucene索引。因此,我需要任何建议,我应该使用什么,如何将Lucene与本体领域以及诸如此类的东西结合起来。
谢谢,
发布于 2011-04-18 03:35:40
在Lucene,你可能会做一些类似的事情
protected Document createDocumentFromTuple(Tuple t) {
Document doc = new Document(); // this is the Lucene document to create
String docid = createId(t);
doc.add(new Field("id", docid, Field.Store.YES, Field.Index.NOT_ANALYZED );
doc.add(new Field("name", t.getName(), Field.Store.YES, Field.Index.NOT_ANALYZED );
doc.add(new Field("author", t.getAuthor(), Field.Store.YES, Field.Index.NOT_ANALYZED );
doc.add(new Field("book", t.getBook(), Field.Store.YES, Field.Index.NOT_ANALYZED );
return doc;
}这假设这三个字段不应该被某个分析器分解为组成项;如果这不是一个正确的假设,那么将最后一个参数更改为Field.Index.ANALYZED。
Solr等价物(如果您不分析字段,这可能更有意义)将是
protected SolrInputDocument createIndexableDocument(Tuple t) {
SolrInputDocument doc = new SolrInputDocument();
String docid = createId(t);
doc.addField("id", docid);
doc.addField("name", t.getName());
doc.addField("author", t.getAuthor());
doc.addField("book", t.getBook());
return doc;
}在Solr中,服务器端配置确定存储哪些字段、如何解析这些字段等。
在每种情况下,您都需要弄清楚如何为每个元组创建一个唯一的id。一种方法是生成三个值的连接(带有分隔符)的散列。
https://stackoverflow.com/questions/5692597
复制相似问题