Search in sources :

Example 1 with CSVLoader

use of org.apache.solr.handler.loader.CSVLoader in project lucene-solr by apache.

the class UpdateRequestHandler method createDefaultLoaders.

protected Map<String, ContentStreamLoader> createDefaultLoaders(NamedList args) {
    SolrParams p = null;
    if (args != null) {
        p = SolrParams.toSolrParams(args);
    }
    Map<String, ContentStreamLoader> registry = new HashMap<>();
    registry.put("application/xml", new XMLLoader().init(p));
    registry.put("application/json", new JsonLoader().init(p));
    registry.put("application/csv", new CSVLoader().init(p));
    registry.put("application/javabin", new JavabinLoader().init(p));
    registry.put("text/csv", registry.get("application/csv"));
    registry.put("text/xml", registry.get("application/xml"));
    registry.put("text/json", registry.get("application/json"));
    pathVsLoaders.put(JSON_PATH, registry.get("application/json"));
    pathVsLoaders.put(DOC_PATH, registry.get("application/json"));
    pathVsLoaders.put(CSV_PATH, registry.get("application/csv"));
    pathVsLoaders.put(BIN_PATH, registry.get("application/javabin"));
    return registry;
}
Also used : ContentStreamLoader(org.apache.solr.handler.loader.ContentStreamLoader) HashMap(java.util.HashMap) CSVLoader(org.apache.solr.handler.loader.CSVLoader) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) SolrParams(org.apache.solr.common.params.SolrParams) MapSolrParams(org.apache.solr.common.params.MapSolrParams) JsonLoader(org.apache.solr.handler.loader.JsonLoader) JavabinLoader(org.apache.solr.handler.loader.JavabinLoader) XMLLoader(org.apache.solr.handler.loader.XMLLoader)

Example 2 with CSVLoader

use of org.apache.solr.handler.loader.CSVLoader in project lucene-solr by apache.

the class CSVRequestHandlerTest method testCommitWithin.

@Test
public void testCommitWithin() throws Exception {
    String csvString = "id;name\n123;hello";
    SolrQueryRequest req = req("separator", ";", "commitWithin", "200");
    SolrQueryResponse rsp = new SolrQueryResponse();
    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
    CSVLoader loader = new CSVLoader();
    loader.load(req, rsp, new ContentStreamBase.StringStream.StringStream(csvString), p);
    AddUpdateCommand add = p.addCommands.get(0);
    assertEquals(200, add.commitWithin);
    req.close();
}
Also used : SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) BufferingRequestProcessor(org.apache.solr.update.processor.BufferingRequestProcessor) CSVLoader(org.apache.solr.handler.loader.CSVLoader) AddUpdateCommand(org.apache.solr.update.AddUpdateCommand) Test(org.junit.Test)

Example 3 with CSVLoader

use of org.apache.solr.handler.loader.CSVLoader in project lucene-solr by apache.

the class MetricsCollectorHandler method init.

@Override
public void init(NamedList initArgs) {
    super.init(initArgs);
    if (initArgs != null) {
        params = SolrParams.toSolrParams(initArgs);
    } else {
        params = new ModifiableSolrParams();
    }
    loaders.put("application/xml", new XMLLoader().init(params));
    loaders.put("application/json", new JsonLoader().init(params));
    loaders.put("application/csv", new CSVLoader().init(params));
    loaders.put("application/javabin", new JavabinLoader().init(params));
    loaders.put("text/csv", loaders.get("application/csv"));
    loaders.put("text/xml", loaders.get("application/xml"));
    loaders.put("text/json", loaders.get("application/json"));
}
Also used : CSVLoader(org.apache.solr.handler.loader.CSVLoader) JsonLoader(org.apache.solr.handler.loader.JsonLoader) JavabinLoader(org.apache.solr.handler.loader.JavabinLoader) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams) XMLLoader(org.apache.solr.handler.loader.XMLLoader)

Aggregations

CSVLoader (org.apache.solr.handler.loader.CSVLoader)3 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)2 JavabinLoader (org.apache.solr.handler.loader.JavabinLoader)2 JsonLoader (org.apache.solr.handler.loader.JsonLoader)2 XMLLoader (org.apache.solr.handler.loader.XMLLoader)2 HashMap (java.util.HashMap)1 MapSolrParams (org.apache.solr.common.params.MapSolrParams)1 SolrParams (org.apache.solr.common.params.SolrParams)1 ContentStreamLoader (org.apache.solr.handler.loader.ContentStreamLoader)1 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)1 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)1 AddUpdateCommand (org.apache.solr.update.AddUpdateCommand)1 BufferingRequestProcessor (org.apache.solr.update.processor.BufferingRequestProcessor)1 Test (org.junit.Test)1