James Thronton提供了一个很好的例子,说明如何配置灯泡使用全文索引作为所有neo4j字段的默认索引:https://gist.github.com/espeed/3025438
然而,有没有一种方法可以手动管理全文索引,使它们只覆盖某些节点类型的某些属性?如果是,怎么做?
关于如何在没有模型的灯泡中进行选择性索引的回答…
- https://stackoverflow.com/a/20046763/161085
如果您不想使用FulltextIndex
作为默认索引(可能是出于性能原因),您可以手动put
要索引的值:
>>> from bulbs.neo4jserver import Graph, FulltextIndex
>>> from bulbs.element import Vertex
>>> index_name="fulltext_vertex"
>>> g = Graph()
>>> g.vertices.fulltext = g.factory.get_index(Vertex, FulltextIndex, index_name)
>>> james = g.vertices.create(name="James Thornton", city="Dallas")
>>> g.vertices.fulltext.put(james.eid, name=james.name)
>>> vertices = g.vertices.fulltext.query(name="James")
>>> vertices.next()
看到……
- 灯泡文档http://bulbflow.com/docs/api/bulbs/neo4jserver/indices/#fulltext-index
- 指数https://github.com/espeed/bulbs/blob/master/bulbs/neo4jserver/index.py L228
- 全文https://github.com/espeed/bulbs/blob/master/bulbs/neo4jserver/index.py L483
为了使全文索引行为自动化而不使全文索引成为默认索引,使用一个Bulbs Model
并创建一个自定义Graph
对象。
查看我对如何自定义灯泡模型的回答…
- 是否有一个等效的在灯泡框架中提交neo4j