Sorry for the additional message, the disclaimer was missing. Disclaimer: The code that was used was taken from the following site: http://e-mats.org/2008/04/using-solrj-a-short-guide-to-getting-started-with-solrj/ .
ahammad wrote: > > Hello, > > I played around some more with it and I found out that I was pointing my > constructor to an older class that doesn't have the MultiCore capability. > > This is what I did to set up the shards: > > query.setParam("shards", > "localhost:8080/solr/core0/,localhost:8080/solr/core1/"); > > I do have a new issue with this though. Here is how the results are > displayed: > > QueryResponse qr = server.query(query); > > SolrDocumentList sdl = qr.getResults(); > > System.out.println("Found: " + sdl.getNumFound()); > System.out.println("Start: " + sdl.getStart()); > System.out.println("Max Score: " + sdl.getMaxScore()); > System.out.println("--------------------------------"); > > ArrayList<HashMap<String, Object>> hitsOnPage = new > ArrayList<HashMap<String, Object>>(); > > for(SolrDocument d : sdl) > { > > HashMap<String, Object> values = new HashMap<String, > Object>(); > > for(Iterator<Map.Entry<String, Object>> i = d.iterator(); > i.hasNext(); ) > { > Map.Entry<String, Object> e2 = i.next(); > > values.put(e2.getKey(), e2.getValue()); > } > > hitsOnPage.add(values); > > String outputString = new String( values.get("title") ); > System.out.println(outputString); > } > > The field "title" is one of the common fields that is shared between the > two schemas. When I print the results of my query, I get null for > everything. However, the result of sdl.getNumFound() is correct, so I know > that both cores are being accessed. > > Is there a difference with how SolrJ handles multicore requests? > > Disclaimer: The code > > > > ahammad wrote: >> >> Hello, >> >> I have a MultiCore install of solr with 2 cores with different schemas >> and such. Querying directly using http request and/or the solr interface >> works very well for my purposes. >> >> I want to have a proper search interface though, so I have some code that >> basically acts as a link between the server and the front-end. Basically, >> depending on the options, the search string is built, and when the search >> is submitted, that string gets passed as an http request. The code then >> would parse through the xml to get the information. >> >> This method works with shards because I can add the shards parameter >> straight into the link that I end up hitting. Although this is currently >> functional, I was thinking of using SolrJ simply because it is simpler to >> use and would cut down the amount of code. >> >> The question is, how would I be able to define the shards in my query, so >> that when I do search, I hit both shards and get mixed results back? >> Using http requests, it's as simple as adding a shard=core0,core1 >> snippet. What is the equivalent of this in SolrJ? >> >> BTW, I do have some SolrJ code that is able to query and return results, >> but for a single core. I am currently using CommonsHttpSolrServer for >> that, not the Embedded one. >> >> Cheers >> > > -- View this message in context: http://www.nabble.com/Using-SolrJ-with-multicore-shards-tp23834518p23838988.html Sent from the Solr - User mailing list archive at Nabble.com.