lucene and ontology
I do not have much experience with Lucene, but I need to finish a research. I want to use Lucene indexing based on ontology. So, I need any kind of advice, what should I use, how to combine Lucene with ontology domain and thing开发者_StackOverflow社区s like that.
Thanks,
- Lucky
In Lucene, you might do something like
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;
}
This assumes that the three fields should not be decomposed into constituent terms by some Analyzer; if that's not a correct assumption, change the last parameter to Field.Index.ANALYZED
.
The Solr equivalent (which might make more sense if you are not analyzing the fields, would be
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;
}
In Solr, the server-side configuration determines which fields are stored, how they are parsed, etc.
In each case, you will need to figure out how to create a unique id for each Tuple. One way to do it is to generate a hash of the concatenation (with delimiters) of the three values.
精彩评论