Spring数据neo4j GraphProperty注释 - 缺少索引

时间:2014-04-13 14:29:00

标签: scala neo4j spring-data-neo4j

在阅读GraphProperty的文档时,可以发现将此注释添加到字段Automatically indexes the propertyhttp://docs.spring.io/spring-data/data-neo4j/docs/3.0.1.RELEASE/api/org/springframework/data/neo4j/annotation/GraphProperty.html

但看起来并非如此(至少3.0.1)。如果我理解这一点,SDN 3.0.1默认使用基于标签的索引。这是我的班级:

object Neo4jAnnotations {
    type GraphId = org.springframework.data.neo4j.annotation.GraphId @field
    type GraphProperty = org.springframework.data.neo4j.annotation.GraphProperty @field
    type Fetch = org.springframework.data.neo4j.annotation.Fetch @field
    type RelatedTo = org.springframework.data.neo4j.annotation.RelatedTo @field
    type Id = org.springframework.data.annotation.Id @field
    type Indexed = org.springframework.data.neo4j.annotation.Indexed @field
    type NodeEntity = org.springframework.data.neo4j.annotation.NodeEntity
}

import Neo4jAnnotations._
@NodeEntity
case class FlightDesignator(@Indexed @GraphProperty(propertyType = classOf[String]) carrier: Carrier,
                            @GraphProperty(propertyType = classOf[java.lang.Integer]) flightNumber: FlightNumber,
                            @GraphProperty(propertyType = classOf[String]) suffix: Option[Suffix] = None,
                            @GraphId id: java.lang.Long = null) {

  private def this() = this(null, null, null)
}

和我的配置:

@Configuration
@EnableNeo4jRepositories(Array("persistence.common.repository", "persistence.set.repository", "persistence.list.repository"))
class Neo4jConfiguration extends org.springframework.data.neo4j.config.Neo4jConfiguration {

  private final val Path = "/db/graph.db"

  /*
  Packages that specify where to look for entity classes, if missing SDN does not create label based indexes.
  http://stackoverflow.com/questions/22089640/neo4j-cannot-perform-data-updates-in-a-transaction-that-has-performed-schema-u
   */
  setBasePackage("domain.common", "domain.set", "domain.list")

  @Bean
  def graphDatabaseService(): GraphDatabaseService = new GraphDatabaseFactory().newEmbeddedDatabase(Path);

}

现在,当我加载我的上下文时:

val a = new AnnotationConfigApplicationContext(classOf[Neo4jConfiguration])

在我的日志中我可以看到:

16:18:26.233 [main] DEBUG o.s.d.n.s.schema.SchemaIndexProvider - CREATE INDEX ON :`FlightDesignator`(`carrier`)
16:18:26.233 [main] DEBUG o.s.d.n.s.query.CypherQueryEngine - Executing cypher query: CREATE INDEX ON :`FlightDesignator`(`carrier`) params {}
16:18:27.005 [main] DEBUG o.s.d.n.s.schema.SchemaIndexProvider - CREATE INDEX ON :`FlightDesignator`(`carrier`)
16:18:27.005 [main] DEBUG o.s.d.n.s.query.CypherQueryEngine - Executing cypher query: CREATE INDEX ON :`FlightDesignator`(`carrier`) params {}
16:18:27.315 [main] DEBUG o.s.d.n.s.schema.SchemaIndexProvider - CREATE INDEX ON :`FlightDesignator`(`carrier`)
16:18:27.316 [main] DEBUG o.s.d.n.s.query.CypherQueryEngine - Executing cypher query: CREATE INDEX ON :`FlightDesignator`(`carrier`) params {}
16:18:27.339 [main] DEBUG o.s.d.n.s.schema.SchemaIndexProvider - CREATE INDEX ON :`FlightDesignator`(`carrier`)
16:18:27.339 [main] DEBUG o.s.d.n.s.query.CypherQueryEngine - Executing cypher query: CREATE INDEX ON :`FlightDesignator`(`carrier`) params {}

当我使用schema执行neo4j-shell命令时,我可以看到:

Indexes
  ON :FlightDesignator(carrier) ONLINE  

但是没有使用GraphProperty和w / o Indexed注释的其他属性的索引。这是一个错误还是只是有人忘了更新javadoc?

0 个答案:

没有答案