....or of course you could just put it all in one index. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Mattias Persson Sent: Wednesday, August 10, 2011 3:31 PM To: Neo4j user discussions Subject: Re: [Neo4j] Graph database index | query across indices
Compound query between two indices isn't possible, but you could just query both and intersect the node set with the end or start node set from the relationships. 2011/7/27 sambodhi sagi <[email protected]> > Hi ! > > I am facing some problem with indexing. My graph looks like this: > > > > > Say, I want to query products for a particular category (say 'Phone,Mobiles > and telecoms') AND having text 'attractive' in 'details' field. I created > two indices: one for Relationship 'RelProductIndex' and one for product > 'ProductIndex'. Algo for what I exactly want to achieve : > > typeHits = relProdctIndex.query( "type:Product", phoneAndTelecomCatNode, > null ); > for each typeHits { > productsInCatList.add(typeHits.getEndNode()); > } > > productsTextSearchHits = productIndex.query("details", "attractive"); > > resultantProducts = common set between productsInCatList and > productsTextSearchHits > > My query is something like this > > QUERY-1 AND QUERY-2 > > QUERY-1 : EndNodes (say end node is a product) of a relationship of type > 'Product' (this query is for RelProductIndex) > QUERY-2 : products which has text 'mobile' (this query is for > ProductsIndex) > > So basically what it requires is *compound query across two indices*. > Normally we donot do compound queries across indices but am not sure how to > handle this.* One solution* I can think of is to add 'details' property to > the relationship Product also. In this case I can use only relationship > index: > > typeHits = relProdctIndex.query( "type:Product AND details:attractive", > phoneAndTelecomCatNode, null ); > > Problem I see with this approach is, I would end up indexing same field(or > key) in two different indices (Product node and Product relationship). This > might hit the performance.* Can there be a better approach to handle this?* > _______________________________________________ > Neo4j mailing list > [email protected] > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [[email protected]] Hacker, Neo Technology www.neotechnology.com _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list [email protected] https://lists.neo4j.org/mailman/listinfo/user

