You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by Marko Rodriguez <ok...@gmail.com> on 2016/10/03 16:56:07 UTC
Re: [TinkerPop] Interaction of "not" and "match" steps
Hello,
Note that I just pushed a fix to tp31/ and up-merged to master/. Thus, your traversal will work as expected in 3.1.5 and 3.2.3.
https://github.com/apache/tinkerpop/commit/c7f42d827414ea7dced0549c02bbc37f40666849 <https://github.com/apache/tinkerpop/commit/c7f42d827414ea7dced0549c02bbc37f40666849>
gremlin> g = TinkerFactory.createModern().traversal()
==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
gremlin> g.V().not(match(
......1> __.as("a").values("age").as("b"),
......2> __.as("a").values("name").as("c")).
......3> where("b", eq("c")).
......4> select("a")).
......5> values("name")
==>marko
==>vadas
==>lop
==>josh
==>ripple
==>peter
gremlin>
Thanks for the find,
Marko.
http://markorodriguez.com
> On Oct 3, 2016, at 10:33 AM, Daniel Kuppitz <me...@gremlin.guru> wrote:
>
> Looks like you've found a bug in NotStep. Here are 2 ugly workarounds:
>
> 1. Enable path computations:
>
> g.withPath().V().not(match(...))
>
> 2. Add requirements in the parent traversal:
>
> g.V().as("a").not(match(...)).select("a")
>
> Cheers,
> Daniel
>
> On Mon, Oct 3, 2016 at 4:56 PM, <lists+gremlin-users@krejci.pw <ma...@krejci.pw>> wrote:
> As I said, we generate the query based on inputs. The "match" part needs to
> sometimes be negated, sometimes not. So my initial approach to this was to
> simply leave the query "snippet" as is and just negate it when needed. That's
> when I discovered this problem.
>
> While in this simplified example P.eq -> P.neq is indeed the simplest
> solution, bringing it back to our codebase would be more difficult, because
> the "real" query is more complex. I simplified the query to illustrate the
> strange behavior...
>
> On Monday, October 3, 2016 4:43:00 PM CEST Daniel Kuppitz wrote:
>
> Why so complicated? This should provide the correct result:
>
>
> g.V().match(
> __.as("a").values("propertyA").as("propA"),
> __.as("a").values("propertyB").as("propB")
> ).where("propA", neq("propB")).select("a")
>
>
> Another way would be:
>
>
> g.V().filter(valueMap("propertyA","propertyB").where("propertyA",
> neq("propertyB")))
>
>
> Cheers,
> Daniel
>
>
>
>
> On Mon, Oct 3, 2016 at 4:17 PM, <lists+gremlin-users@krejci.pw <ma...@krejci.pw>> wrote:
>
> Hi,
>
> In the query below, I'm trying to find all vertices that have "propA" and
> "propB" properties set to a different value. The below query complains about
> an unsolvable match pattern. Is that a bug or am I doing something wrong in
> the query?
>
> graph.addVertex("propertyA", 1, "propertyB", 2);
>
> graph.traversal().V().not(
> __.match(
> __.as("a").values("propertyA").as("propA"),
> __.as("a").values("propertyB").as("propB"))
> .where("propA", P.eq("propB"))
> .select("a")
> );
>
> Because the above is a (simplified) generated query, I'm using a "not" step
> instead of simply using P.neq.
>
> Regards,
>
> --
> Lukas Krejci
>
> --
> You received this message because you are subscribed to the Google Groups
> "Gremlin-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to gremlin-users+unsubscribe@googlegroups.com <ma...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/
> gremlin-users/50896973.2DW1h1rdbW%40localhost.localdomain <https://groups.google.com/d/msgid/gremlin-users/50896973.2DW1h1rdbW%40localhost.localdomain>.
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Gremlin-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to gremlin-users+unsubscribe@googlegroups.com <ma...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ <https://groups.google.com/d/msgid/>
> gremlin-users/CA%2Bf9seWqOM%3DXCT0nXuZ%3DfTu3neW_3uiZCsEAQmeHLBqfsB4baw
> %40mail.gmail.com <http://40mail.gmail.com/>.
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
>
>
>
>
> --
> Lukas Krejci
>
> --
> You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com <ma...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/3581542.WupXtlzBPQ%40localhost.localdomain <https://groups.google.com/d/msgid/gremlin-users/3581542.WupXtlzBPQ%40localhost.localdomain>.
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com <ma...@googlegroups.com>.
> To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/CA%2Bf9seXz8yNOGJpPaPvLW3WDNKCAQxfxsPVhJUzo%2B_uwpPKG7A%40mail.gmail.com <https://groups.google.com/d/msgid/gremlin-users/CA%2Bf9seXz8yNOGJpPaPvLW3WDNKCAQxfxsPVhJUzo%2B_uwpPKG7A%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.