incubator-hugegraph icon indicating copy to clipboard operation
incubator-hugegraph copied to clipboard

有版本计划支持全文检索吗

Open sharfy opened this issue 7 years ago • 3 comments

有版本计划支持全文检索吗

sharfy avatar Dec 20 '18 05:12 sharfy

目前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("海淀区"));

配置不同的分词可能会有不同的查询结果。

不知道这样的查询是否能满足你的需求?

Linary avatar Dec 20 '18 14:12 Linary

那么 请问有什么方法可以 g.V().hasLabel("person").has("address", Text.contains("中国海淀区"));这种场景下能搜到 北京市海淀区 这个顶点吗

zx-6017 avatar Oct 30 '20 03:10 zx-6017

@Linary

zx-6017 avatar Nov 04 '20 03:11 zx-6017