You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@storm.apache.org by srdo <gi...@git.apache.org> on 2017/08/12 07:34:19 UTC

[GitHub] storm pull request #2108: STORM-2508:storm-solr enhancement: update solrj to...

Github user srdo commented on a diff in the pull request:

    https://github.com/apache/storm/pull/2108#discussion_r132810994
  
    --- Diff: external/storm-solr/src/main/java/org/apache/storm/solr/schema/builder/SolrClientSchemaBuilder.java ---
    @@ -0,0 +1,95 @@
    +/*
    + * SolrClientSchemaBuilder.java
    + * Copyright 2017 Qunhe Tech, all rights reserved.
    + * Qunhe PROPRIETARY/CONFIDENTIAL, any form of usage is subject to approval.
    + */
    +
    +package org.apache.storm.solr.schema.builder;
    +
    +import org.apache.solr.client.solrj.SolrServerException;
    +import org.apache.solr.client.solrj.request.schema.FieldTypeDefinition;
    +import org.apache.solr.client.solrj.request.schema.SchemaRequest;
    +import org.apache.solr.client.solrj.response.schema.SchemaRepresentation;
    +import org.apache.solr.client.solrj.response.schema.SchemaResponse;
    +import org.apache.storm.solr.client.SolrClientFactory;
    +import org.apache.storm.solr.schema.CopyField;
    +import org.apache.storm.solr.schema.FieldType;
    +import org.apache.storm.solr.schema.Schema;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.List;
    +import java.util.Map;
    +
    +/**
    + * <p>this Class build the {@link Schema} by Solr Schema API.</p>
    + *
    + * @see <a href="https://cwiki.apache.org/confluence/display/solr/Schema+API">Solr Schema API</a>
    + * @author alei
    + */
    +public class SolrClientSchemaBuilder implements SchemaBuilder {
    +
    +    private static final Logger LOG = LoggerFactory.getLogger(SolrClientSchemaBuilder.class);
    +
    +    private Schema schema;
    +
    +    public SolrClientSchemaBuilder(String collection, SolrClientFactory factory) throws IOException, SolrServerException {
    +        SchemaRequest request = new SchemaRequest();
    +        SchemaResponse response = request.process(factory.getSolrClient(), collection);
    +        SchemaRepresentation representation = response.getSchemaRepresentation();
    +        schema = convert(representation);
    +    }
    +
    +    @Override
    +    public Schema getSchema() {
    +        return schema;
    +    }
    +
    +    private Schema convert(final SchemaRepresentation representation) {
    +        Schema converted = new Schema();
    +        converted.setUniqueKey(representation.getUniqueKey());
    +        converted.setName(representation.getName());
    +        converted.setVersion(String.valueOf(representation.getVersion()));
    --- End diff --
    
    Nit: If this is a float, shouldn't we keep it that way in Schema?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---