Example usage for org.apache.solr.client.solrj SolrClient addBeans

List of usage examples for org.apache.solr.client.solrj SolrClient addBeans

Introduction

In this page you can find the example usage for org.apache.solr.client.solrj SolrClient addBeans.

Prototype

public UpdateResponse addBeans(final Iterator<?> beanIterator) throws SolrServerException, IOException 

Source Link

Document

Adds the beans supplied by the given iterator.

Usage

From source file:net.yacy.cora.federate.solr.instance.ServerShard.java

License:Open Source License

/**
 * Adds a collection of beans/*from  w w  w. j a va2 s  .com*/
 * @param beans  the collection of beans
 * @throws IOException If there is a low-level I/O error.
 */
@Override
public UpdateResponse addBeans(Collection<?> beans) throws SolrServerException, IOException {
    if (!this.writeEnabled)
        return _dummyOKResponse;
    UpdateResponse ur = null;
    for (SolrClient s : this.shards)
        ur = s.addBeans(beans);
    return ur;
}

From source file:richtercloud.solr.bean.indexing.NewMain.java

/**
 * @param args the command line arguments
 *///from  www. jav  a 2s.  c  om
public static void main(String[] args) {
    SolrClient solrServer;
    solrServer = new HttpSolrClient.Builder("http://localhost:8983/solr/test1").build();
    List<MyBean> myBeans = new LinkedList<>(
            Arrays.asList(new MyBean("a", "1", 1), new MyBean("b", "2", 2), new MyBean("c", "3", 3)));
    String searchTerm = "a";
    try {
        solrServer.addBeans(myBeans);
        solrServer.commit();
        SolrQuery solrQuery = new SolrQuery();
        solrQuery.set("q", searchTerm);
        QueryResponse queryResponse = solrServer.query(solrQuery);
        List<MyBean> foundDocuments = queryResponse.getBeans(MyBean.class);
        System.out.println(foundDocuments);
    } catch (SolrServerException | IOException ex) {
        throw new RuntimeException(ex);
    }
}