On Thu, Jun 25, 2009 at 2:05 PM, Ian Smith <ian.sm...@gossinteractive.com>wrote:

>
> Can you or someone else possibly help me with a working SolrCore
> constructor call?
>
>
Here is a working example for single index/core:

        System.setProperty("solr.solr.home",
"/home/shalinsmangar/work/oss/branch-1.3/example/solr");
        CoreContainer.Initializer initializer = new
CoreContainer.Initializer();
        CoreContainer coreContainer = initializer.initialize();
        EmbeddedSolrServer server = new EmbeddedSolrServer(coreContainer,
"");
        SolrInputDocument doc = new SolrInputDocument();
        doc.addField("id", "101");
        server.add(doc);
        server.commit(true, true);
        SolrQuery query = new SolrQuery();
        query.setQuery("id:101");
        QueryResponse response = server.query(query);
        SolrDocumentList list = response.getResults();
        System.out.println("list.size() = " + list.size());
        coreContainer.shutdown();

Make sure your dataDir in solrconfig.xml is fixed (absolute) otherwise your
data directory will get created relative to the current working directory
(or you could set a system property for solr.data.dir)

Hope that helps. I'll add it to the wiki too.
-- 
Regards,
Shalin Shekhar Mangar.

Reply via email to