wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes Using solr with java best practices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Using solr with java best practices" Watch "Using solr with java best practices" New topic
Author

Using solr with java best practices

Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
hi
i wanted to know anbody has any experience of working with solrJ a Java client to hit solr data repository.
i went through some sample code and upon running it ruturns solar document which matches my search.
is there a way to convert those solr document into my javabean domain model.

If the response returned was raw xml we could use castor or apache xfire beans to map raw xml to java objects.
Wondering how can we do with mapping solrdocument with java objects rather than initializing them with hands

any advice.
Rashid
Pawankumar Jajara
Greenhorn

Joined: Mar 29, 2011
Posts: 4
I am also looking for a similar solution. Is there any way how I can map my .xml file in eXist server and use Apache Solr to query data in that XML file. The user interface comes from a html document.
Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
Wow its beena while i asked this question, but we have solrj extensively after that.
Using SolrJ you can have annotation defined which is mapped to the schema file just like any other ORM mapping.
SolrJ annotation does all the dirty work of converting solr documents to your java beans

QueryResponse qr = server.query(query);
domainBean = qr.getBeans(domainBean.class)

where domain bean is something like
public class DomainBean{

@Field("id")
private String id = null;
@Field("c_title")
private String title = null;
@Field("c_description")
private String description = null;

Hope it helps
Pawankumar Jajara
Greenhorn

Joined: Mar 29, 2011
Posts: 4
Yes it helped a lot. Thanks for the information. The Google has very few web pages for Apache Solr which makes newbies life pretty hard.

Thanks,
Pawankumar Jajara
Darvesh Niz
Ranch Hand

Joined: May 12, 2008
Posts: 119
ONce place where i got a lot of help was
the nabble solr forums and the solr wiki

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using solr with java best practices