[ 
https://issues.apache.org/jira/browse/TINKERPOP-1804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16382218#comment-16382218
 ] 

Daniel Kuppitz commented on TINKERPOP-1804:
-------------------------------------------

This is, what the strategy should do:

*Apply vertex property filter:*
{noformat}
g.V().hasLabel("person").has('location', 'seattle').
  filter(properties().or(hasLabel(neq('location')), hasNot('endTime'))).
  valueMap()
{noformat}

*Reapply has-filters (don't remove the original has-steps as they could be 
relevant for index lookups):*
{noformat}
g.V().hasLabel("person").has('location', 'seattle').
  filter(properties().and(
    or(hasLabel(neq('location')), hasNot('endTime')),    // user-specified 
vertex property filter
    hasLabel('location').hasValue('seattle'))).          // rewritten 
has-step(s)
  valueMap()
{noformat}

*Rewrite valueMap:*
{noformat}
g.V().hasLabel("person").has('location', 'seattle').
  filter(properties().and(or(hasLabel(neq('location')), hasNot('endTime')), 
hasLabel('location').hasValue('seattle'))).
  local(properties().or(hasLabel(neq('location')), 
hasNot('endTime')).group().by(key).by(value))
{noformat}

The rewrite of {{valueMap}} is already done differently in the strategy, so 
this step can be ignored. I just did it to show the correct output without 
using the strategy:

{noformat}
gremlin> g.V().hasLabel("person").has('location', 'seattle').
......1>   filter(properties().and(or(hasLabel(neq('location')), 
hasNot('endTime')), hasLabel('location').hasValue('seattle'))).
......2>   local(properties().or(hasLabel(neq('location')), 
hasNot('endTime')).group().by(key).by(value))
==>[name:[matthias],location:[seattle]]
gremlin>
{noformat}

> Has step doesn't consider strategy vertexProperty filters
> ---------------------------------------------------------
>
>                 Key: TINKERPOP-1804
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-1804
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: process
>    Affects Versions: 3.2.3
>            Reporter: Simone Cattani
>            Priority: Major
>
> Has step, when used in a traversal defined with strategies, doesn't consider 
> filters applied on properties by the strategies
> Let's consider the crew example adding an old location for Marko, in Seattle, 
> the current Matthias' location.
> {code}
> graph = TinkerFactory.createTheCrew()
> g = graph.traversal()
> g.V().has('name', 'marko').property('location', 'seattle', 'startTime', 1994, 
> 'endTime', 1997)
> {code}
> Defining a strategy that considers just current location I can correctly 
> obtain the list of current locations
> {code}
> g.withStrategies(SubgraphStrategy.build().vertexProperties(or(hasLabel(neq('location')),hasNot('endTime'))).create()).V().hasLabel("person").valueMap()
> ==>[name:[marko],location:[santa fe]]
> ==>[name:[stephen],location:[purcellville]]
> ==>[name:[matthias],location:[seattle]]
> ==>[name:[daniel],location:[aachen]]
> {code}
> But requiring people (currently) living in Seattle, I obtain Marko, too
> {code}
> g.withStrategies(SubgraphStrategy.build().vertexProperties(or(hasLabel(neq('location')),hasNot('endTime'))).create()).V().hasLabel("person").has('location',
>  'seattle').valueMap()
> ==>[name:[marko],location:[santa fe]]
> ==>[name:[matthias],location:[seattle]]
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to