Hi,

> Is it possible that when we create the Automatic Index, that we can filter it 
> on specific nodes?

No.

>  Referring to the diagram below, we have a Node with a property _Type= 
> Agency. I would like to create an index (aidx-agency-key) based on Key but 
> only for the Nodes with _Type=Agency.
> So, pseudo code would be:
> g.createAutomaticIndex('myIndex', Vertex.class, new pair[,] 
> {Node._Type=Agency},“Key”)
>  
> Is this the right approach, or are we doing something wrong

You can't do that with AutomaticIndices.

> The solution we want is to be able to count all the Nodes in the database 
> with a property _Type=Agency and property Key=”myKey” or to checking the 
> existence of a Node  with _Type=”Agency” and Key=”myKey”.

Yea. The not so efficient way to do that is:

g.idx('myIndex').get('_Type','Agency')[[key:'myKey']].count()

1. get agencies
2. iterate and filter out those whose key doesn't equal 'myKey'
3. count up what gets emitted from the pipeline.

Perhaps Neo4j guys can help as there are some things with Lucene indices and 
the 'AND' clause. Given that AutomaticIndex, when used with Neo4jGraph, is just 
a wrapper to Lucene, I believe you can do stuff like '_Type AND Key=myKey' ? -- 
I've never done it so I don't know... Rick, on this list, knows the ins and 
outs of indices.... 

> 
> and to do a count or check if it exists would be multiple filters
> g.V[[_Typey:Agency],[ Name:Acme]].count()

Yea, thats a bit excessive -- too many things to iterate through. You can do 
the previous:
        g.idx('myIndex').get('_Type','Agency')[[key:'myKey']].count()

> 

Good luck,
Marko.

http://markorodriguez.com

_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to