Re: Special Circumstances for embedded Solr

2011-02-24 Thread Devangini

Can you please show me how an http implementation of solrj querying can be
converted to one for embedded solr with the help of an example?
-- 
View this message in context: 
http://lucene.472066.n3.nabble.com/Special-Circumstances-for-embedded-Solr-tp833409p2566768.html
Sent from the Solr - User mailing list archive at Nabble.com.


Re: Special Circumstances for embedded Solr

2011-02-24 Thread Tarjei Huse
On 02/24/2011 12:16 PM, Devangini wrote:
 Can you please show me how an http implementation of solrj querying can be
 converted to one for embedded solr with the help of an example?
Hi, heres an example that almost compiles. You should be able to get
going with this.
T

class EmbeddedSolrExample {

public static void main (String[] args) {

setupSolrContainer();
addDocument();
   


SolrDocumentList getResults(QueryResponse response) {
if (response.getStatus() != 0) {
return new SolrDocumentList();
}
return response.getResults();
}
private void addDocument() throws IncompleteDocumentException,
SolrServerException, IOException {

SolrInputDocument res = new SolrInputDocument();
res.setField(body, test);
res.setField(id, 12);


UpdateResponse s = server.add(res);
assertEquals((int) s.getStatus(), 0 );
server.commit();

SolrDocumentList res = getResults(search(test));
System.out.println(I got  + res.size() +  documents);

}

private void setupSolrContainer() throws
ParserConfigurationException, IOException, SAXException,
IncompleteDocumentException, SolrServerException {
File home = new File(/tmp/solr);
File f = new File(home, solr.xml);
CoreContainer container = new CoreContainer();
container.load(/tmp/solr, f);

server = new EmbeddedSolrServer(container, model);
addDocument();
}

QueryResponse search(String words) throws SolrServerException {
SolrQuery query = new SolrQuery();
query.addField(id).addField(body).addField(score);
query.setTimeAllowed(1000);
query.setRows(50);
query.set(q, words);
query.setSortField(timestamp, ORDER.desc); // sorter på dato
return server.query(query);

}

-- 
Regards / Med vennlig hilsen
Tarjei Huse
Mobil: 920 63 413



Re: Special Circumstances for embedded Solr

2010-05-21 Thread Ryan McKinley

 Any other commonly compelling reasons to use SolrJ?

The most compelling reason (I think) is that if you program against
the Solrj API, you can switch between embedded/http/streaming
implementations without changing anything.

This is great for our app that is either run as a small local instance
of a big enterprise setting.

ryan


Special Circumstances for embedded Solr

2010-05-20 Thread Ken Krugler

Hi all,

We'd started using embedded Solr back in 2007, via a patched version  
of the in-progress 1.3 code base.


I recently was reading http://wiki.apache.org/solr/EmbeddedSolr, and  
wondered about the paragraph that said:
The simplest, safest, way to use Solr is via Solr's standard HTTP  
interfaces. Embedding Solr is less flexible, harder to support, not  
as well tested, and should be reserved for special circumstances.


Given the current state of SolrJ, and the expected roadmap for Solr in  
general, what would be some guidelines for special circumstances  
that warrant the use of SolrJ?


I know what ours were back in 2007 - namely:

- we had multiple indexes, but didn't want to run multiple webapps  
(now handled by multi-core)
- we needed efficient generation of updated indexes, without  
generating lots of HTTP traffic (now handled by DIH, maybe with  
specific extensions?)
- we wanted tighter coupling of the front-end API with the back-end  
Solr search system, since this was an integrated system in the hands  
of customers - no just restart the webapp container option if  
anything got wedged (might still be an issue?)


Any other commonly compelling reasons to use SolrJ?

Thanks,

-- Ken



Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c   w e b   m i n i n g