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 (C) 2020 Graylog, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* .
*/
package org.graylog2.indexer;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.graylog2.indexer.indexset.IndexSetConfig;
import org.graylog2.plugin.Message;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/**
* Representing the message type mapping in Elasticsearch. This is giving ES more
* information about what the fields look like and how it should analyze them.
*/
public abstract class IndexMapping implements IndexMappingTemplate {
public static final String TYPE_MESSAGE = "message";
@Override
public Map toTemplate(IndexSetConfig indexSetConfig, String indexPattern, int order) {
return messageTemplate(indexPattern, indexSetConfig.indexAnalyzer(), order);
}
protected Map analyzerKeyword() {
return ImmutableMap.of("analyzer_keyword", ImmutableMap.of(
"tokenizer", "keyword",
"filter", "lowercase"));
}
public Map messageTemplate(final String template, final String analyzer, final int order) {
final Map settings = Collections.singletonMap(
"analysis", Collections.singletonMap("analyzer", analyzerKeyword())
);
final Map mappings = mapping(analyzer);
return createTemplate(template, order, settings, mappings);
}
Map createTemplate(String template, int order, Map settings, Map mappings) {
return ImmutableMap.of(
"template", template,
"order", order,
"settings", settings,
"mappings", mappings
);
}
protected Map mapping(String analyzer) {
return ImmutableMap.of(TYPE_MESSAGE, messageMapping(analyzer));
}
protected Map messageMapping(final String analyzer) {
return ImmutableMap.of(
"properties", fieldProperties(analyzer),
"dynamic_templates", dynamicTemplate(),
"_source", enabled());
}
private Map> internalFieldsMapping() {
return ImmutableMap.of("internal_fields",
ImmutableMap.of(
"match", "gl2_*",
"match_mapping_type", "string",
"mapping", notAnalyzedString())
);
}
protected List