0

假设2个节点之间存在如下关系

start --> "follows" --> end

我想创建一个名为“Relations”的索引并将上述关系添加到索引中。我如何在 Scala 或 Java 中做到这一点?

我试过这样做:

override def NodeIndexConfig = ("Relations", Some(Map("provider" -> "lucene", "type" -> "fulltext")))::NIL
    val rel_name = group+"_Voteup"
    val relation = user_node --> rel_name --> item_node

    val Relation_Index = getNodeIndex("Relations").get
    val rel_value = user_id+item_id+rel_name
    Relation_Index += (relation,"rel_id",rel_value)

但是,我收到类型不匹配错误。

4

1 回答 1

1

您可能应该使用关系索引而不是节点索引,例如

override def RelationIndexConfig = ("Relations", Some(Map("provider" -> "lucene", "type" -> "fulltext")))::Nil
val rel_name = group+"_Voteup"
val relation = user_node --> rel_name --> item_node

val Relation_Index = getRelationIndex("Relations")
val rel_value = user_id+item_id+rel_name
Relation_Index.foreach(_ += (relation,"rel_id",rel_value))

注意:我删除了调用并对可选值index.get使用了“更安全”的调用。foreach

于 2013-04-04T09:57:18.983 回答