Search in sources :

Example 1 with SORT_VALUE

use of ddf.catalog.solr.offlinegazetteer.GazetteerConstants.SORT_VALUE in project ddf by codice.

the class CatalogGazetteerForwardingPlugin method convert.

protected static SolrInputDocument convert(Metacard metacard) {
    SolrInputDocument solrDoc = new SolrInputDocument();
    Consumer<String> getAttrAndAdd = (attributeName) -> Optional.ofNullable(getStringAttribute(metacard, attributeName)).ifPresent(attributeValue -> solrDoc.addField(GAZETTEER_TO_CATALOG.inverse().get(attributeName), attributeValue));
    getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(DESCRIPTION));
    getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(FEATURE_CODE));
    getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(NAME));
    getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(ID));
    getAttrAndAdd.accept(GAZETTEER_TO_CATALOG.get(COUNTRY_CODE));
    Optional.of(metacard).map(m -> getStringAttribute(m, GAZETTEER_TO_CATALOG.get(LOCATION))).ifPresent(v -> solrDoc.addField(LOCATION, v));
    Optional.of(metacard).map(m -> m.getAttribute(GAZETTEER_TO_CATALOG.get(POPULATION))).map(Attribute::getValue).filter(Long.class::isInstance).map(Long.class::cast).ifPresent(v -> solrDoc.addField(POPULATION, v));
    Optional.of(metacard).map(m -> m.getAttribute(GAZETTEER_TO_CATALOG.get(SORT_VALUE))).map(Attribute::getValue).filter(Integer.class::isInstance).map(Integer.class::cast).ifPresent(v -> solrDoc.addField(SORT_VALUE, v));
    return solrDoc;
}
Also used : COLLECTION_NAME(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.COLLECTION_NAME) PreQueryPlugin(ddf.catalog.plugin.PreQueryPlugin) SolrClient(org.codice.solr.client.solrj.SolrClient) SolrClientFactory(org.codice.solr.factory.SolrClientFactory) LoggerFactory(org.slf4j.LoggerFactory) DESCRIPTION(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.DESCRIPTION) DeleteResponse(ddf.catalog.operation.DeleteResponse) SUGGEST_DICT_KEY(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.SUGGEST_DICT_KEY) Update(ddf.catalog.operation.Update) PluginExecutionException(ddf.catalog.plugin.PluginExecutionException) PostIngestPlugin(ddf.catalog.plugin.PostIngestPlugin) SolrServerException(org.apache.solr.client.solrj.SolrServerException) CreateResponse(ddf.catalog.operation.CreateResponse) Metacard(ddf.catalog.data.Metacard) SUGGEST_Q_KEY(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.SUGGEST_Q_KEY) QueryRequest(ddf.catalog.operation.QueryRequest) COUNTRY_CODE(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.COUNTRY_CODE) Nullable(javax.annotation.Nullable) GAZETTEER_REQUEST_HANDLER(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.GAZETTEER_REQUEST_HANDLER) GAZETTEER_METACARD_TAG(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.GAZETTEER_METACARD_TAG) Logger(org.slf4j.Logger) NAME(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.NAME) SORT_VALUE(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.SORT_VALUE) SUGGEST_BUILD_KEY(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.SUGGEST_BUILD_KEY) StopProcessingException(ddf.catalog.plugin.StopProcessingException) IOException(java.io.IOException) GAZETTEER_TO_CATALOG(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.GAZETTEER_TO_CATALOG) Collectors(java.util.stream.Collectors) Serializable(java.io.Serializable) Consumer(java.util.function.Consumer) SUGGESTION_BUILD_KEY(ddf.catalog.Constants.SUGGESTION_BUILD_KEY) List(java.util.List) Attribute(ddf.catalog.data.Attribute) FEATURE_CODE(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.FEATURE_CODE) SolrQuery(org.apache.solr.client.solrj.SolrQuery) POPULATION(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.POPULATION) Optional(java.util.Optional) LOCATION(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.LOCATION) ID(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.ID) UpdateResponse(ddf.catalog.operation.UpdateResponse) SUGGEST_DICT(ddf.catalog.solr.offlinegazetteer.GazetteerConstants.SUGGEST_DICT) SolrInputDocument(org.apache.solr.common.SolrInputDocument) SolrInputDocument(org.apache.solr.common.SolrInputDocument)

Aggregations

SUGGESTION_BUILD_KEY (ddf.catalog.Constants.SUGGESTION_BUILD_KEY)1 Attribute (ddf.catalog.data.Attribute)1 Metacard (ddf.catalog.data.Metacard)1 CreateResponse (ddf.catalog.operation.CreateResponse)1 DeleteResponse (ddf.catalog.operation.DeleteResponse)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 Update (ddf.catalog.operation.Update)1 UpdateResponse (ddf.catalog.operation.UpdateResponse)1 PluginExecutionException (ddf.catalog.plugin.PluginExecutionException)1 PostIngestPlugin (ddf.catalog.plugin.PostIngestPlugin)1 PreQueryPlugin (ddf.catalog.plugin.PreQueryPlugin)1 StopProcessingException (ddf.catalog.plugin.StopProcessingException)1 COLLECTION_NAME (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.COLLECTION_NAME)1 COUNTRY_CODE (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.COUNTRY_CODE)1 DESCRIPTION (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.DESCRIPTION)1 FEATURE_CODE (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.FEATURE_CODE)1 GAZETTEER_METACARD_TAG (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.GAZETTEER_METACARD_TAG)1 GAZETTEER_REQUEST_HANDLER (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.GAZETTEER_REQUEST_HANDLER)1 GAZETTEER_TO_CATALOG (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.GAZETTEER_TO_CATALOG)1 ID (ddf.catalog.solr.offlinegazetteer.GazetteerConstants.ID)1