asp微信网站,wordpress图片缝隙,免费的推广网站,网站源码安装教程IndexLabel 用来定义索引类型#xff0c;描述索引的约束信息#xff0c;主要是为了方便查询。
IndexLabel 允许定义的约束信息包括#xff1a;name、baseType、baseValue、indexFeilds、indexType#xff0c;下面逐一介绍。
name: 属性的名字#xff0c;用来区分不同的 …IndexLabel 用来定义索引类型描述索引的约束信息主要是为了方便查询。
IndexLabel 允许定义的约束信息包括name、baseType、baseValue、indexFeilds、indexType下面逐一介绍。
name: 属性的名字用来区分不同的 IndexLabel不允许有同名的属性
interfaceparammust setindexLabel(String name)nameybaseType: 表示要为 VertexLabel 还是 EdgeLabel 建立索引, 与下面的 baseValue 配合使用 baseValue: 指定要建立索引的 VertexLabel 或 EdgeLabel 的名称
interfaceparamdescriptiononV(String baseValue)baseValuebuild index for VertexLabel: baseValueonE(String baseValue)baseValuebuild index for EdgeLabel: baseValue
indexFeilds: 要在哪些属性上建立索引可以是为多列建立联合索引
interfaceparamdescriptionby(String... fields)filesallow to build index for multi fields for secondary index
indexType: 建立的索引类型目前支持五种即 Secondary、Range、Search、Shard 和 Unique。 Secondary 支持精确匹配的二级索引允许建立联合索引联合索引支持索引前缀搜索 单个属性支持相等查询比如person顶点的city属性的二级索引可以用g.V().has(city, 北京)查询city属性值是北京的全部顶点联合索引支持前缀查询和相等查询比如person顶点的city和street属性的联合索引可以用g.V().has (city, 北京).has(street, 中关村街道)查询city属性值是北京且street属性值是中关村的全部顶点或者g.V() .has(city, 北京)查询city属性值是北京的全部顶点 secondary index的查询都是基于是或者相等的查询条件不支持部分匹配 Range 支持数值类型的范围查询 必须是单个数字或者日期属性比如person顶点的age属性的范围索引可以用g.V().has(age, P.gt(18))查询age属性值大于18的顶点。除了P.gt()以外还支持P.gte(), P.lte(), P.lt(), P.eq(), P.between(), P.inside()和P.outside()等Search 支持全文检索的索引 必须是单个文本属性比如person顶点的address属性的全文索引可以用g.V().has(address, Text .contains(大厦)查询address属性中包含大厦的全部顶点 search index的查询是基于是或者包含的查询条件 Shard 支持前缀匹配 数字范围查询的索引 N个属性的分片索引支持前缀相等情况下的范围查询比如person顶点的city和age属性的分片索引可以用g.V().has (city, 北京).has(age, P.between(18, 30))查询city属性是北京且年龄大于等于18小于30的全部顶点shard index N个属性全是文本属性时等价于secondary indexshard index只有单个数字或者日期属性时等价于range index shard index可以有任意数字或者日期属性但是查询时最多只能提供一个范围查找条件且该范围查找条件的属性的前缀属性都是相等查询条件 Unique 支持属性值唯一性约束即可以限定属性的值不重复允许联合索引但不支持查询 单个或者多个属性的唯一性索引不可用来查询只可对属性的值进行限定当出现重复值时将报错
interfaceindexTypedescriptionsecondary()Secondarysupport prefix searchrange()Rangesupport range(numeric or date type) searchsearch()Searchsupport full text searchshard()Shardsupport prefix range(numeric or date type) searchunique()Uniquesupport unique props value, not support search
2.5.2 创建 IndexLabel
schema.indexLabel(personByAge).onV(person).by(age).range().ifNotExist().create();
schema.indexLabel(createdByDate).onE(created).by(date).secondary().ifNotExist().create();
schema.indexLabel(personByLived).onE(person).by(lived).search().ifNotExist().create();
schema.indexLabel(personByCityAndAge).onV(person).by(city, age).shard().ifNotExist().create();
schema.indexLabel(personById).onV(person).by(id).unique().ifNotExist().create();2.5.3 删除 IndexLabel
schema.indexLabel(personByAge).remove()2.5.4 查询 IndexLabel
// 获取IndexLabel对象
schema.getIndexLabel(personByAge)// 获取property key属性
schema.getIndexLabel(personByAge).baseType()
schema.getIndexLabel(personByAge).baseValue()
schema.getIndexLabel(personByAge).indexFields()
schema.getIndexLabel(personByAge).indexType()
schema.getIndexLabel(personByAge).name()