基本上我确实有非常简单的数据库,我想用 Lucene 来索引。域是:
// Person domain
class Person {
Set<Pair> keys;
}
// Pair domain
class Pair {
KeyItem keyItem;
String value;
}
// KeyItem domain, name is unique field within the DB (!!)
class KeyItem{
String name;
}
我有几千万个配置文件和几亿个对,但是,由于大部分 KeyItem 的“名称”字段重复,所以只有几十个 KeyItem 实例。提出该结构以保存 KeyItem 实例。
基本上,任何带有任何字段的配置文件都可以保存到该结构中。假设我们已经配置了属性
- name: Andrew Morton
- eduction: University of New South Wales,
- country: Australia,
- occupation: Linux programmer.
为了存储它,我们将有一个 Profile 实例,4 个 KeyItem 实例:姓名、教育、国家和职业,以及 4 个具有值的 Pair 实例:“Andrew Morton”、“University of New South Wales”、“Australia”和“Linux程序员”。
所有其他配置文件将引用(全部或部分)相同的 KeyItem 实例:姓名、教育、国家和职业。
我的问题是,如何索引所有这些,以便我可以在 Profile 中搜索 KeyItem::name 和 Pair::value 的某些特定值。理想情况下,我希望这种查询起作用:
姓名:Andrew* 职业:Linux*
我应该创建自定义索引器和搜索器吗?或者我可以使用标准的并以某种方式将 KeyItem 和 Pair 映射为 Lucene 组件?