Hello, Continuing to have fun with joins, I finally figured a way to make my joins works. Suppose I have inserted data as bellow, using solrj. If I want to select a parent (room) that has both:
- a keyboard and a mouse - a monitor and a tablet In my data, bellow, only room2 should be a match. I was able to get this working using the following solr query: q= *:* AND _query_:"{!join from=root_id to=id}acessory1:Keyboard AND acessory2:Mouse" AND _query_:"{!join from=root_id to=id}acessory1:Monitor AND acessory2:Tablet" As we can see, I am using nested queries. I have a result for each join and the results are merged as I was expecting. The problem is I can have about 20 nested joins on a query, sometimes. Question: How is it performed in Solr, under the hood? If I have 100 million documents, will all my joins (20 joins, for instance) be applied on 100 million documents? Or they will be applied on the result of the prior join? For instance, suppose my first query returns 10 documents (selected among 100 million). Will the other queries apply only in this result or they will apply on the entire index and then the result is merged? Data inserted with solrJ: public void insertDocuments() throws DataGrinderException, SolrServerException, IOException, DGIndexException { SolrServer solr = DGSolrServer.get(); // Add parent SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", "room1"); doc.addField("cor_parede", "white"); doc.addField("num_cadeiras", 34); solr.add(doc); // Add children SolrInputDocument doc2 = new SolrInputDocument(); doc2.addField("id", "computer1"); doc2.addField("acessory1", "Keyboard"); doc2.addField("acessory2", "Mouse"); doc2.addField("root_id", "room1"); solr.add(doc2); doc2 = new SolrInputDocument(); doc2.addField("id", "computer2"); doc2.addField("acessory1", "Monitor"); doc2.addField("acessory2", "Mouse"); doc2.addField("root_id", "room1"); solr.add(doc2); doc2 = new SolrInputDocument(); doc2.addField("id", "computer3"); doc2.addField("acessory1", "Keyboard"); doc2.addField("acessory2", "Camera"); doc2.addField("root_id", "room1"); solr.add(doc2); doc2 = new SolrInputDocument(); doc2.addField("id", "computer4"); doc2.addField("acessory1", "Tablet"); doc2.addField("acessory2", "Mouse USB"); doc2.addField("root_id", "room1"); solr.add(doc2); // Add parent doc = new SolrInputDocument(); doc.addField("id", "room2"); doc.addField("cor_parede", "black"); doc.addField("num_cadeiras", 35); solr.add(doc); // Add children doc2 = new SolrInputDocument(); doc2.addField("id", "computer5"); doc2.addField("acessory1", "Keyboard"); doc2.addField("acessory2", "Mouse"); doc2.addField("root_id", "room2"); solr.add(doc2); doc2 = new SolrInputDocument(); doc2.addField("id", "computer6"); doc2.addField("acessory1", "Monitor"); doc2.addField("acessory2", "Tablet"); doc2.addField("root_id", "room2"); solr.add(doc2); UpdateResponse response = solr.add(doc); if (response.getStatus() != 0) throw new DGIndexException("Could not insert document to solr!"); solr.commit(); } Best regards, -- Marcelo Elias Del Valle http://mvalle.com - @mvallebr