You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Bing Li <lb...@gmail.com> on 2011/01/22 07:41:57 UTC
SolrJ Tutorial
Hi, all,
In the past, I always used SolrNet to interact with Solr. It works great.
Now, I need to use SolrJ. I think it should be easier to do that than
SolrNet since Solr and SolrJ should be homogeneous. But I cannot find a
tutorial that is easy to follow. No tutorials explain the SolrJ programming
step by step. No complete samples are found. Could anybody offer me some
online resources to learn SolrJ?
I also noticed Solr Cell and SolrJ POJO. Do you have detailed resources to
them?
Thanks so much!
LB
Re: SolrJ Tutorial
Posted by Bing Li <lb...@gmail.com>.
I got the solution. Attach one complete sample code I made as follows.
Thanks,
LB
package com.greatfree.Solr;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.client.solrj.beans.Field;
import java.net.MalformedURLException;
public class SolrJExample
{
public static void main(String[] args) throws MalformedURLException,
SolrServerException
{
SolrServer solr = new CommonsHttpSolrServer("
http://192.168.210.195:8080/solr/CategorizedHub");
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
QueryResponse rsp = solr.query(query);
SolrDocumentList docs = rsp.getResults();
System.out.println(docs.getNumFound());
try
{
SolrServer solrScore = new CommonsHttpSolrServer("
http://192.168.210.195:8080/solr/score");
Score score = new Score();
score.id = "4";
score.type = "modern";
score.name = "iphone";
score.score = 97;
solrScore.addBean(score);
solrScore.commit();
}
catch (Exception e)
{
System.out.println(e.toString());
}
}
}
On Sat, Jan 22, 2011 at 3:58 PM, Lance Norskog <go...@gmail.com> wrote:
> The unit tests are simple and show the steps.
>
> Lance
>
> On Fri, Jan 21, 2011 at 10:41 PM, Bing Li <lb...@gmail.com> wrote:
> > Hi, all,
> >
> > In the past, I always used SolrNet to interact with Solr. It works great.
> > Now, I need to use SolrJ. I think it should be easier to do that than
> > SolrNet since Solr and SolrJ should be homogeneous. But I cannot find a
> > tutorial that is easy to follow. No tutorials explain the SolrJ
> programming
> > step by step. No complete samples are found. Could anybody offer me some
> > online resources to learn SolrJ?
> >
> > I also noticed Solr Cell and SolrJ POJO. Do you have detailed resources
> to
> > them?
> >
> > Thanks so much!
> > LB
> >
>
>
>
> --
> Lance Norskog
> goksron@gmail.com
>
Re: SolrJ Tutorial
Posted by Grijesh <pi...@gmail.com>.
It comes with every solr source code download directory under
src/test
-----
Thanx:
Grijesh
http://lucidimagination.com
--
View this message in context: http://lucene.472066.n3.nabble.com/SolrJ-Tutorial-tp2307113p2631223.html
Sent from the Solr - User mailing list archive at Nabble.com.
Re: SolrJ Tutorial
Posted by Bing Li <lb...@gmail.com>.
Dear Lance,
Could you tell me where I can find the unit tests code?
I appreciate so much for your help!
Best regards,
LB
On Sat, Jan 22, 2011 at 3:58 PM, Lance Norskog <go...@gmail.com> wrote:
> The unit tests are simple and show the steps.
>
> Lance
>
> On Fri, Jan 21, 2011 at 10:41 PM, Bing Li <lb...@gmail.com> wrote:
> > Hi, all,
> >
> > In the past, I always used SolrNet to interact with Solr. It works great.
> > Now, I need to use SolrJ. I think it should be easier to do that than
> > SolrNet since Solr and SolrJ should be homogeneous. But I cannot find a
> > tutorial that is easy to follow. No tutorials explain the SolrJ
> programming
> > step by step. No complete samples are found. Could anybody offer me some
> > online resources to learn SolrJ?
> >
> > I also noticed Solr Cell and SolrJ POJO. Do you have detailed resources
> to
> > them?
> >
> > Thanks so much!
> > LB
> >
>
>
>
> --
> Lance Norskog
> goksron@gmail.com
>
Re: SolrJ Tutorial
Posted by Lance Norskog <go...@gmail.com>.
The unit tests are simple and show the steps.
Lance
On Fri, Jan 21, 2011 at 10:41 PM, Bing Li <lb...@gmail.com> wrote:
> Hi, all,
>
> In the past, I always used SolrNet to interact with Solr. It works great.
> Now, I need to use SolrJ. I think it should be easier to do that than
> SolrNet since Solr and SolrJ should be homogeneous. But I cannot find a
> tutorial that is easy to follow. No tutorials explain the SolrJ programming
> step by step. No complete samples are found. Could anybody offer me some
> online resources to learn SolrJ?
>
> I also noticed Solr Cell and SolrJ POJO. Do you have detailed resources to
> them?
>
> Thanks so much!
> LB
>
--
Lance Norskog
goksron@gmail.com