1

TP2 0.54 -> TP3 titan 1.0 / Tinkerpop 3.01 からの移行中

異なる Vertex インデックスのプロパティ間で Predicate Text を使用して「論理 OR」を作成する 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'...

- - - - - - - - - - 期待される結果: - - - - - -

プロパティ「storyContent」に一致するすべての頂点を返したい text contains prefix 、または大文字と小文字が一致するプロパティ「userContent」を持つすべての頂点を返します。
この場合、v1 と v2 を返します。v3 が一致せず、v4 が重複しているため、重複除去ステップで無視する必要があるためです。

 g.V().has("storyContent", textContainsPrefix("ab")) "OR" has("userContent", textContainsPrefix("dc"))

または多分 :

g.V().or(_().has('storyContent', textContainsPrefix("abc")), _().has('userContent', textContainsPrefix("dcc")))

PS、

私は TP3 OR step を dedup で使用すると思っていましたが、gremlin はエラーをスローします...

助けてくれてありがとう

ヴィタリー

4

1 に答える 1

5

それらの線に沿ったものはどうですか:

g.V().or(
    has('storyContent', textContainsPrefix("abc")),
    has('userContent', textContainsPrefix("dcc"))
)

編集 - コメントで述べたように、このクエリはインデックスを使用しません。2 つの個別のクエリに分割する必要があります。

TinkerPop v3.0.1 Drop Step のドキュメントと Titan v1.0.0 Ch. 20 - インデックス パラメーターと全文検索のドキュメント

Titan では、次の前にテキスト述語をインポートする必要がある場合があります。

import static com.thinkaurelius.titan.core.attribute.Text.*

_.()は TinkerPop2 の素材であり、TinkerPop3 では使用されなくなりました。匿名トラバーサルを述語として使用するようになりました。これ__.は、Groovy の予約済みキーワード (例: ) を使用して名前を付けたステップで開始する必要がある場合があります__.in()

于 2016-04-14T21:29:11.057 に答える