use of org.apache.solr.client.solrj.SolrServer in project stanbol by apache.
the class SolrYardTest method initYard.
@BeforeClass
public static final void initYard() throws YardException, IOException {
// get the working directory
// use property substitution to test this feature!
String prefix = System.getProperty("basedir") == null ? "." : "${basedir}";
String solrServerDir = prefix + TEST_INDEX_REL_PATH;
log.info("Test Solr Server Directory: " + solrServerDir);
SolrYardConfig config = new SolrYardConfig(TEST_YARD_ID, TEST_SOLR_CORE_NAME);
config.setName("Solr Yard Test");
config.setDescription("The Solr Yard instance used to execute the Unit Tests defined for the Yard Interface");
config.setAllowInitialisation(true);
//for unit testing we want immidiate commits (required after STANBOL-1092
// as the default changed to false)
config.setImmediateCommit(true);
//init the ManagedSolrServer used for the UnitTest
System.setProperty(ManagedSolrServer.MANAGED_SOLR_DIR_PROPERTY, solrServerDir);
IndexReference solrServerRef = IndexReference.parse(config.getSolrServerLocation());
solrServerProvider = StandaloneEmbeddedSolrServerProvider.getInstance();
SolrServer server = solrServerProvider.getSolrServer(solrServerRef, config.isAllowInitialisation() ? config.getIndexConfigurationName() : null);
//Optional support for the nsPrefix service
final NamespacePrefixService nsPrefixService;
ServiceLoader<NamespacePrefixService> spsl = ServiceLoader.load(NamespacePrefixService.class);
Iterator<NamespacePrefixService> it = spsl.iterator();
if (it.hasNext()) {
nsPrefixService = it.next();
} else {
nsPrefixService = null;
}
yard = new SolrYard(server, config, nsPrefixService);
}
use of org.apache.solr.client.solrj.SolrServer in project apex-malhar by apache.
the class AbstractSolrInputOperator method emitTuples.
@Override
public void emitTuples() {
SolrParams solrQueryParams = getQueryParams();
try {
SolrServer solrServer = solrServerConnector.getSolrServer();
QueryResponse response = solrServer.query(solrQueryParams);
SolrDocumentList queriedDocuments = response.getResults();
for (SolrDocument solrDocument : queriedDocuments) {
emitTuple(solrDocument);
lastEmittedTuple = solrDocument;
lastEmittedTimeStamp = System.currentTimeMillis();
logger.debug("Emiting document: " + solrDocument.getFieldValue("name"));
}
} catch (SolrServerException ex) {
throw new RuntimeException("Unable to fetch documents from Solr server", ex);
}
}
Aggregations