Which version are you using?

On Fri, Jun 6, 2014 at 8:00 PM, Aru Sahni <[email protected]> wrote:

> Hi all,
>
> My simplified data model is as follows:
>
> Entity {
>    source}
> Person {
>    first_name}
>
> And I have the following indexes:
>
> ON :Entity(source)     ONLINE
> ON :Person(first_name) ONLINE
>
> I've got a handful of nodes on my graph.  Each node has two labels, Entity
> and Person.  I want to query for all people with a given source that have a
> certain first name.  The naive way of doing this is:
>
> MATCH (n:Person)
> WHERE n.first_name = 'John' AND n.source = "form1"
> RETURN n;
>
> The profiler shows:
>
> Filter(pred="Property(n,source(10)) == Literal(form1)", _rows=2, _db_hits=2)
> SchemaIndex(identifier="n", _db_hits=0, _rows=2, label="Person",
>
>
>     query="Literal(John)", identifiers=["n"], property="first_name",
>
>
>     producer="SchemaIndex")
>
> So, obviously it's not using the Entity(source) index.  Time to declare it.
>
> MATCH (n:Entity:Person)
> USING INDEX n:Person(first_name)
> USING INDEX n:Entity(source)
> WHERE n.first_name = "John" AND n.source = "form1"
> RETURN n;
>
> The profiler shows that it's hitting both indexes:
>
> SchemaIndex(identifier="n", _db_hits=0, _rows=8, label="Entity",
>
>
>     query="Literal(form1)", identifiers=["n"], property="source",
>
>
>     producer="SchemaIndex")
> SchemaIndex(identifier="n", _db_hits=0, _rows=2, label="Person",
>
>
>     query="Literal(John)", identifiers=["n"], property="first_name",
>
>
>     producer="SchemaIndex")
>
> However, the returned rows appear to show records with first_name=John OR
> source=form1.  There are duplicate nodes returned as well, but nothing
> DISTINCT can't fix.
>
> Switching the order of the USING statements still duplicates result nodes,
> but they seem to reflect the proper intersection.
>
> Any insight into this behavior (and guidance) would be greatly appreciated.
>
> Regards,
> ~Aru
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to