如何使用谓词文本在Titan 1.0/TP3 3.01中的顶点索引之间进行逻辑OR

Vit*_*lyT 1 gremlin titan tinkerpop tinkerpop3

在我从TP2 0.54 - > TP3 titan 1.0/Tinkerpop 3.01迁移期间

我正在尝试构建gremlin查询,该查询使用谓词文本在不同顶点索引的属性之间进行"逻辑或运算"

就像是:

-------------------预先定义的ES指数:------------------

tg = TitanFactory.open('../conf/titan-cassandra-es.properties')
tm = tg.openManagement();
g=tg.traversal();

      PropertyKey pNodeType = createPropertyKey(tm, "nodeType", String.class, Cardinality.SINGLE);
      PropertyKey userContent = createPropertyKey(tm, "storyContent", String.class, Cardinality.SINGLE);
      PropertyKey storyContent = createPropertyKey(tm, "userContent", String.class, Cardinality.SINGLE);

            //"storyContent" : is elasticsearch backend index - mixed
            tm.buildIndex(indexName, Vertex.class).addKey(storyContent, Mapping.TEXTSTRING.asParameter()).ib.addKey(pNodeType, Mapping.TEXTSTRING.asParameter()).buildMixedIndex("search");

            //"userContent" : is elasticsearch backend index - mixed
            tm.buildIndex(indexName, Vertex.class).addKey(userContent, Mapping.TEXTSTRING.asParameter()).ib.addKey(pNodeType, Mapping.TEXTSTRING.asParameter()).buildMixedIndex("search");


            v1= g.addVertex()
            v1.property("nodeType","USER")
            v1.property("userContent" , "dccsdsadas")

            v2= g.addVertex()
            v2.property("nodeType","STORY")
            v2.property("storyContent" , "abdsds")

            v3= g.addVertex()
            v3.property("nodeType","STORY")
            v3.property("storyContent" , "xxxx")              

            v4= g.addVertex()
            v4.property("nodeType","STORY")
            v4.property("storyContent" , "abdsds") , etc'...
Run Code Online (Sandbox Code Playgroud)

- - - - - - - - - - 预期结果: - - - - - -

我想返回所有具有属性"storyContent"的顶点匹配文本包含前缀,或者所有具有匹配其大小写的属性"userContent"的顶点.
在这种情况下返回v1和v2,因为v3不匹配且v4重复,因此必须通过重复数据删除步骤忽略它

 g.V().has("storyContent", textContainsPrefix("ab")) "OR" has("userContent", textContainsPrefix("dc"))
Run Code Online (Sandbox Code Playgroud)

或者可能 :

g.V().or(_().has('storyContent', textContainsPrefix("abc")), _().has('userContent', textContainsPrefix("dcc")))
Run Code Online (Sandbox Code Playgroud)

PS,

我认为使用TP3或步骤与重复数据删除,但gremlin抛出错误...

谢谢你的帮助

维塔利

jbm*_*sso 5

那些方面的东西怎么样:

g.V().or(
    has('storyContent', textContainsPrefix("abc")),
    has('userContent', textContainsPrefix("dcc"))
)
Run Code Online (Sandbox Code Playgroud)

编辑 - 如评论中所述,此查询不会使用任何索引.它必须分成两个单独的查询.

请参阅TinkerPop v3.0.1 Drop Step文档和Titan v1.0.0 Ch.20 - 索引参数和全文搜索文档.

使用Titan,您可能必须先导入文本谓词:

import static com.thinkaurelius.titan.core.attribute.Text.*
Run Code Online (Sandbox Code Playgroud)

_.()是TinkerPop2材料,不再用于TinkerPop3.您现在使用匿名遍历作为谓词,有时必须从__.Groovy中以保留关键字命名的步骤开始(例如__.in()).

  • 此查询不会使用任何索引.要实际使用2个已定义的索引,您必须将其拆分为2个单独的查询. (3认同)