use of org.apache.solr.client.solrj.request.json.DirectJsonQueryRequest in project Anserini by castorini.
the class SolrEndToEndTest method testIndexAndSearch.
@Test
public void testIndexAndSearch() throws Exception {
String schemaAdjustmentFile = getSchemaAdjustmentFile();
if (schemaAdjustmentFile != null) {
// update schema, much like curl -X POST -H 'Content-type:application/json' --data-binary SCHEMA_NAME.json http://localhost:8983/solr/COLLECTION_NAME/schema
String schemaJson = Files.readString(getFile(schemaAdjustmentFile).toPath());
DirectJsonQueryRequest schemaRequest = new DirectJsonQueryRequest(schemaJson, params(CommonParams.QT, "/schema"));
QueryResponse response = schemaRequest.process(client, getCollectionName());
assertEquals(0, response.getStatus());
}
IndexArgs indexArgs = getIndexArgs();
IndexCollection indexRunner = getIndexRunner(indexArgs);
indexRunner.run();
SearchSolr.Args searchArgs = getSearchArgs();
SearchSolr searchRunner = getSearchRunner(searchArgs);
searchRunner.runTopics();
BufferedReader br = new BufferedReader(new FileReader(searchArgs.output));
String[] ref = getRefRankingResult();
String s;
int cnt = 0;
while ((s = br.readLine()) != null) {
assertEquals(ref[cnt], s);
cnt++;
}
assertEquals(cnt, ref.length);
FileUtils.deleteQuietly(new File(searchArgs.output));
}
Aggregations