Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Copyright 2017 JanusGraph Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.janusgraph.diskstorage.es.compat;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.janusgraph.core.Cardinality;
import org.janusgraph.core.attribute.Geo;
import org.janusgraph.core.schema.Mapping;
import org.janusgraph.core.schema.Parameter;
import org.janusgraph.diskstorage.es.ElasticSearchRequest;
import org.janusgraph.diskstorage.indexing.IndexFeatures;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_ANALYZER;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_ID_KEY;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_LANG_KEY;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_PARAMS_FIELDS_KEY;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_PARAMS_KEY;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_SCRIPT_KEY;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_SOURCE_KEY;
import static org.janusgraph.diskstorage.es.ElasticSearchConstants.ES_TYPE_KEY;
/**
* Base class for building Elasticsearch mapping and query objects.
*/
public abstract class AbstractESCompat {
static final Map MATCH_ALL = ImmutableMap.of("match_all", Collections.EMPTY_MAP);
static IndexFeatures.Builder coreFeatures() {
return new IndexFeatures.Builder()
.setDefaultStringMapping(Mapping.TEXT)
.supportedStringMappings(Mapping.TEXT, Mapping.TEXTSTRING, Mapping.STRING)
.setWildcardField("_all")
.supportsCardinality(Cardinality.SINGLE)
.supportsCardinality(Cardinality.LIST)
.supportsCardinality(Cardinality.SET)
.supportsNanoseconds()
.supportsCustomAnalyzer()
.supportsGeoExists()
.supportNotQueryNormalForm()
;
}
public abstract IndexFeatures getIndexFeatures();
public Map createKeywordMapping() {
return ImmutableMap.of(ES_TYPE_KEY, "keyword");
}
public Map createTextMapping(String textAnalyzer) {
final ImmutableMap.Builder builder = ImmutableMap.builder().put(ES_TYPE_KEY, "text");
return (textAnalyzer != null ? builder.put(ES_ANALYZER, textAnalyzer) : builder).build();
}
public String scriptLang() {
return "painless";
}
public ImmutableMap.Builder prepareScript(String source) {
Map script = ImmutableMap.of(ES_SOURCE_KEY, source,
ES_LANG_KEY, scriptLang());
return ImmutableMap.builder().put(ES_SCRIPT_KEY, script);
}
public ImmutableMap.Builder prepareStoredScript(String scriptId, List