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

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

Introduction

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

Prototype

public UpdateResponse add(String collection, Iterator<SolrInputDocument> docIterator)
        throws SolrServerException, IOException 

Source Link

Document

Adds the documents supplied by the given iterator.

Usage

From source file:com.frank.search.solr.core.SolrTemplate.java

License:Apache License

@Override
public UpdateResponse saveBean(final Object objectToAdd, final int commitWithinMs) {
    assertNoCollection(objectToAdd);//  w  w  w.  j  a v a2s.  c o m
    return execute(new SolrCallback<UpdateResponse>() {
        @Override
        public UpdateResponse doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
            return solrClient.add(convertBeanToSolrInputDocument(objectToAdd), commitWithinMs);
        }
    });
}

From source file:com.frank.search.solr.core.SolrTemplate.java

License:Apache License

@Override
public UpdateResponse saveBeans(final Collection<?> beansToAdd, final int commitWithinMs) {
    return execute(new SolrCallback<UpdateResponse>() {
        @Override/* w w w  .  jav a  2 s  .  c o  m*/
        public UpdateResponse doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
            return solrClient.add(convertBeansToSolrInputDocuments(beansToAdd), commitWithinMs);
        }
    });
}

From source file:com.frank.search.solr.core.SolrTemplate.java

License:Apache License

@Override
public UpdateResponse saveDocument(final SolrInputDocument documentToAdd, final int commitWithinMs) {
    return execute(new SolrCallback<UpdateResponse>() {
        @Override//  www  . j  a  v a2 s. c om
        public UpdateResponse doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
            return solrClient.add(documentToAdd, commitWithinMs);
        }
    });
}

From source file:com.frank.search.solr.core.SolrTemplate.java

License:Apache License

@Override
public UpdateResponse saveDocuments(final Collection<SolrInputDocument> documentsToAdd,
        final int commitWithinMs) {
    return execute(new SolrCallback<UpdateResponse>() {
        @Override/*from   ww w.  java 2s.  c  o m*/
        public UpdateResponse doInSolr(SolrClient solrClient) throws SolrServerException, IOException {
            return solrClient.add(documentsToAdd, commitWithinMs);
        }
    });
}

From source file:org.intermine.api.searchengine.solr.SolrIndexHandler.java

License:GNU General Public License

private void addSolrDocuments(SolrClient solrClient, List<SolrInputDocument> solrDocumentList)
        throws IOException {
    //Accessing SchemaAPI from solr and create the schema dynamically

    if (solrDocumentList.size() != 0) {

        LOG.debug("Beginning to commit Solr Documents into Solr");

        try {//from  ww w . ja  v a2 s .c  o m
            UpdateResponse response = solrClient.add(solrDocumentList, 30000);

        } catch (SolrServerException e) {

            LOG.error("Error while commiting the SolrInputdocuments to the Solrclient. "
                    + "Make sure the Solr instance is up", e);

            e.printStackTrace();
        }
    }

}

From source file:org.roda.core.index.utils.SolrUtils.java

public static <T extends IsIndexed> void create(SolrClient index, Class<T> classToCreate, T instance)
        throws GenericException {
    try {//  w w w  .j  a  v  a2 s.  c o  m
        index.add(getIndexName(classToCreate).get(0), toSolrDocument(classToCreate, instance));
    } catch (SolrServerException | IOException | NotSupportedException e) {
        throw new GenericException("Error adding instance to index", e);
    }
}