【问题标题】:Titan Indexing With Elastic Search. String Matching Issue使用弹性搜索的 Titan 索引。字符串匹配问题
【发布时间】:2016-01-11 13:06:21
【问题描述】:

我在使用 Titan 进行索引时遇到了一些问题。我将我的索引配置如下:

TitanGraph graph = TitanFactory.open("conf/titan-cassandra-es.properties");
TitanManagement management = graph.openManagement();
String indexKey = "byItemIdentifier";
String propertyKey = "ITEM_IDENTIFIER";
TitanIndex index = management.getGraphIndex(indexKey);
PropertyKey key = management.makePropertyKey(propertyKey).dataType(String.class).make();
management.buildIndex(indexKey, Vertex.class).addKey(key, Mapping.STRING.asParameter()).buildMixedIndex("search");
management.commit();

现在的问题:

Vertex vertex = graph.addVertex();
vertex.property(propertyKey, "www.foo.com/bar");
graph.commit();

然后我尝试以下方法:

graph.traversal().V().has(propertyKey, "foo").hasNext(); //(1)
graph.traversal().V().has(propertyKey, "bar").hasNext(); //(2)
graph.traversal().V().has(propertyKey, "www.foo.com/bar").hasNext(); //(3)

(1) = false(2) = false(3) = false。这是怎么回事? (3) 肯定应该返回 true 吗?我是否配置错误?

【问题讨论】:

  • 不是你的问题的答案,但你真的需要混合索引吗?您可以使用 Titan 的内部复合索引进行相等性测试。就个人而言,由于问题788,我已经竭尽全力避免混合索引。
  • @Ralf 现在我已经改为使用复合索引,这就足够了。感谢您指出问题。

标签: elasticsearch titan tinkerpop3


【解决方案1】:

首先,在您创建索引之后,您应该等待它从安装到注册。这种方法会有所帮助:

// Block until the SchemaStatus transitions from INSTALLED to REGISTERED
ManagementSystem.awaitGraphIndexStatus(graph, vertices_index).status(SchemaStatus.REGISTERED).call();

这会阻止您的代码,直到您的索引后端创建它。

其次,如果图表中已经有一些数据,您必须重新索引您的属性,以便索引后端(Elasticsearch 等)可以知道它。使用这个 Java 方法:

public static void reindexGraph(TitanGraph graph, String myIndex) throws InterruptedException {
    TitanManagement management = graph.openManagement();
    TitanGraphIndex index = management.getGraphIndex(myIndex);
    management.updateIndex(index, SchemaAction.REINDEX);
    management.commit();

    // Enable the index
    ManagementSystem.awaitGraphIndexStatus(graph, myIndex).status(SchemaStatus.ENABLED).call();
    graph.tx().commit();
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-04-02
    • 2018-08-02
    • 2015-12-07
    • 2021-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多