incubator-hugegraph
incubator-hugegraph copied to clipboard
有版本计划支持全文检索吗
有版本计划支持全文检索吗
目前HugeGraph是支持属性的全文检索的,比如顶点的“地址”属性是:“北京市海淀区中关村软件园”,并且给该类顶点的“地址”建立了search索引,在查询时通过"北京市"、“海淀区”是能查到该顶点的。
例子:
// 元数据定义
schema.propertyKey("name").asText().ifNotExist().create();
schema.propertyKey("address").asText().ifNotExist().create();
schema.vertexLabel("person").useCustomizeStringId().properties("name", "address").ifNotExist().create();
schema.indexLabel("personByAddress").onV("person").search().by("address").ifNotExist().create();
// 插入顶点
Vertex A = graph.addVertex(T.label, "person", T.id, "A", "name", "A", "address", "北京市海淀区");
Vertex B = graph.addVertex(T.label, "person", T.id, "B", "name", "B", "address", "北京市朝阳区");
Vertex C = graph.addVertex(T.label, "person", T.id, "C", "name", "C", "address", "武汉市洪山区");
// 根据北京市查询返回“A”和“B”
g.V().hasLabel("person").has("address", Text.contains("北京市"));
// 根据海淀区查询返回"A"
g.V().hasLabel("person").has("address", Text.contains("海淀区"));
配置不同的分词可能会有不同的查询结果。
不知道这样的查询是否能满足你的需求?
那么 请问有什么方法可以 g.V().hasLabel("person").has("address", Text.contains("中国海淀区"));这种场景下能搜到 北京市海淀区 这个顶点吗
@Linary