java geoprocessor,Java ElasticsearchParseException類代碼示例

本文整理匯總了Java中org.elasticsearch.ElasticsearchParseException類的典型用法代碼示例。如果您正苦於以下問題:Java ElasticsearchParseException類的具體用法?Java ElasticsearchParseException怎麽用?Java ElasticsearchParseException使用的例子?那麽恭喜您, 這裏精選的類代碼示例或許可以為您提供幫助。

ElasticsearchParseException類屬於org.elasticsearch包,在下文中一共展示了ElasticsearchParseException類的40個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

示例1: execute

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

@Override

public void execute(IngestDocument document) throws Exception {

String stringValue = document.getFieldValue(field, String.class);

try {

Map mapValue = XContentHelper.convertToMap(JsonXContent.jsonXContent, stringValue, false);

if (addToRoot) {

for (Map.Entry entry : mapValue.entrySet()) {

document.setFieldValue(entry.getKey(), entry.getValue());

}

} else {

document.setFieldValue(targetField, mapValue);

}

} catch (ElasticsearchParseException e) {

throw new IllegalArgumentException(e);

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,

示例2: loadMappings

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public static SortedMap loadMappings(Object configuration, Version indexVersionCreated)

throws ElasticsearchParseException {

if (configuration instanceof Map) {

Map configurations = (Map)configuration;

SortedMap mappings = Maps.newTreeMap();

for (Entry config : configurations.entrySet()) {

String name = config.getKey();

mappings.put(name, loadMapping(name, (Map) config.getValue(), indexVersionCreated));

}

return mappings;

} else if (configuration == null) {

return ContextMapping.EMPTY_MAPPING;

} else {

throw new ElasticsearchParseException("no valid context configuration");

}

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,

示例3: testPutWithErrorResponse

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testPutWithErrorResponse() {

String id = "_id";

Pipeline pipeline = store.get(id);

assertThat(pipeline, nullValue());

ClusterState clusterState = ClusterState.builder(new ClusterName("_name")).build();

PutPipelineRequest putRequest =

new PutPipelineRequest(id, new BytesArray("{\"description\": \"empty processors\"}"), XContentType.JSON);

ClusterState previousClusterState = clusterState;

clusterState = store.innerPut(putRequest, clusterState);

try {

store.innerUpdatePipelines(previousClusterState, clusterState);

fail("should fail");

} catch (ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[processors] required property is missing"));

}

pipeline = store.get(id);

assertThat(pipeline, nullValue());

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:20,

示例4: testBuildWithCountryDbAndCityFields

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testBuildWithCountryDbAndCityFields() throws Exception {

GeoIpProcessor.Factory factory = new GeoIpProcessor.Factory(databaseReaders);

Map config = new HashMap<>();

config.put("field", "_field");

config.put("database_file", "GeoLite2-Country.mmdb.gz");

EnumSet cityOnlyProperties = EnumSet.complementOf(GeoIpProcessor.Property.ALL_COUNTRY_PROPERTIES);

String cityProperty = RandomPicks.randomFrom(Randomness.get(), cityOnlyProperties).toString();

config.put("properties", Collections.singletonList(cityProperty));

try {

factory.create(null, null, config);

fail("Exception expected");

} catch (ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[properties] illegal property value [" + cityProperty +

"]. valid values are [IP, COUNTRY_ISO_CODE, COUNTRY_NAME, CONTINENT_NAME]"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,

示例5: testCreateWithTooManyProcessorTypes

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateWithTooManyProcessorTypes() throws Exception {

Processor processor = new TestProcessor(ingestDocument -> { });

Map registry = new HashMap<>();

registry.put("_first", (r, t, c) -> processor);

registry.put("_second", (r, t, c) -> processor);

ForEachProcessor.Factory forEachFactory = new ForEachProcessor.Factory();

Map config = new HashMap<>();

config.put("field", "_field");

Map processorTypes = new HashMap<>();

processorTypes.put("_first", Collections.emptyMap());

processorTypes.put("_second", Collections.emptyMap());

config.put("processor", processorTypes);

Exception exception = expectThrows(ElasticsearchParseException.class, () -> forEachFactory.create(registry, null, config));

assertThat(exception.getMessage(), equalTo("[processor] Must specify exactly one processor type"));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:17,

示例6: testValidate

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testValidate() throws Exception {

PutPipelineRequest putRequest = new PutPipelineRequest("_id", new BytesArray(

"{\"processors\": [{\"set\" : {\"field\": \"_field\", \"value\": \"_value\", \"tag\": \"tag1\"}}," +

"{\"remove\" : {\"field\": \"_field\", \"tag\": \"tag2\"}}]}"),

XContentType.JSON);

DiscoveryNode node1 = new DiscoveryNode("_node_id1", buildNewFakeTransportAddress(),

emptyMap(), emptySet(), Version.CURRENT);

DiscoveryNode node2 = new DiscoveryNode("_node_id2", buildNewFakeTransportAddress(),

emptyMap(), emptySet(), Version.CURRENT);

Map ingestInfos = new HashMap<>();

ingestInfos.put(node1, new IngestInfo(Arrays.asList(new ProcessorInfo("set"), new ProcessorInfo("remove"))));

ingestInfos.put(node2, new IngestInfo(Arrays.asList(new ProcessorInfo("set"))));

ElasticsearchParseException e =

expectThrows(ElasticsearchParseException.class, () -> store.validatePipeline(ingestInfos, putRequest));

assertEquals("Processor type [remove] is not installed on node [" + node2 + "]", e.getMessage());

assertEquals("remove", e.getHeader("processor_type").get(0));

assertEquals("tag2", e.getHeader("processor_tag").get(0));

ingestInfos.put(node2, new IngestInfo(Arrays.asList(new ProcessorInfo("set"), new ProcessorInfo("remove"))));

store.validatePipeline(ingestInfos, putRequest);

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:24,

示例7: incompatibleSnapshotsFromXContent

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

/**

* Reads the incompatible snapshot ids from x-content, loading them into a new instance of {@link RepositoryData}

* that is created from the invoking instance, plus the incompatible snapshots that are read from x-content.

*/

public RepositoryData incompatibleSnapshotsFromXContent(final XContentParser parser) throws IOException {

List incompatibleSnapshotIds = new ArrayList<>();

if (parser.nextToken() == XContentParser.Token.START_OBJECT) {

while (parser.nextToken() == XContentParser.Token.FIELD_NAME) {

String currentFieldName = parser.currentName();

if (INCOMPATIBLE_SNAPSHOTS.equals(currentFieldName)) {

if (parser.nextToken() == XContentParser.Token.START_ARRAY) {

while (parser.nextToken() != XContentParser.Token.END_ARRAY) {

incompatibleSnapshotIds.add(SnapshotId.fromXContent(parser));

}

} else {

throw new ElasticsearchParseException("expected array for [" + currentFieldName + "]");

}

} else {

throw new ElasticsearchParseException("unknown field name [" + currentFieldName + "]");

}

}

} else {

throw new ElasticsearchParseException("start object expected");

}

return new RepositoryData(this.genId, this.snapshotIds, this.indexSnapshots, incompatibleSnapshotIds);

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:27,

示例8: detectInnerMapper

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

private static Mapper.Builder, ?> detectInnerMapper(ParseContext parseContext,

String fieldName, XContentParser parser) throws IOException {

XContentParser.Token token = parser.currentToken();

if (token == XContentParser.Token.START_ARRAY) {

token = parser.nextToken();

}

// can't use nulls to detect type

while (token == XContentParser.Token.VALUE_NULL) {

token = parser.nextToken();

}

if (token == XContentParser.Token.START_ARRAY) {

throw new ElasticsearchParseException("nested arrays are not supported");

} else if (token == XContentParser.Token.END_ARRAY) {

// array is empty or has only null values

return null;

}

return DocumentParser.createBuilderFromDynamicValue(parseContext, token, fieldName);

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:22,

示例9: load

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

private static ContextMapping load(Map contextConfig, Version indexVersionCreated) {

String name = extractRequiredValue(contextConfig, FIELD_NAME);

String type = extractRequiredValue(contextConfig, FIELD_TYPE);

final ContextMapping contextMapping;

switch (Type.fromString(type)) {

case CATEGORY:

contextMapping = CategoryContextMapping.load(name, contextConfig);

break;

case GEO:

contextMapping = GeoContextMapping.load(name, contextConfig);

break;

default:

throw new ElasticsearchParseException("unknown context type[" + type + "]");

}

DocumentMapperParser.checkNoRemainingFields(name, contextConfig, indexVersionCreated);

return contextMapping;

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:18,

示例10: parseRequest

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

/**

* Parses a {@link RestRequest} body and returns a {@link MultiSearchRequest}

*/

public static MultiSearchRequest parseRequest(RestRequest restRequest, boolean allowExplicitIndex) throws IOException {

MultiSearchRequest multiRequest = new MultiSearchRequest();

if (restRequest.hasParam("max_concurrent_searches")) {

multiRequest.maxConcurrentSearchRequests(restRequest.paramAsInt("max_concurrent_searches", 0));

}

parseMultiLineRequest(restRequest, multiRequest.indicesOptions(), allowExplicitIndex, (searchRequest, parser) -> {

try {

final QueryParseContext queryParseContext = new QueryParseContext(parser);

searchRequest.source(SearchSourceBuilder.fromXContent(queryParseContext));

multiRequest.add(searchRequest);

} catch (IOException e) {

throw new ElasticsearchParseException("Exception when parsing search request", e);

}

});

return multiRequest;

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:22,

示例11: parseFetchedDoc

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

private ParsedDocument parseFetchedDoc(PercolateContext context, BytesReference fetchedDoc, IndexService documentIndexService, String index, String type) {

ParsedDocument doc = null;

XContentParser parser = null;

try {

parser = XContentFactory.xContent(fetchedDoc).createParser(fetchedDoc);

MapperService mapperService = documentIndexService.mapperService();

DocumentMapperForType docMapper = mapperService.documentMapperWithAutoCreate(type);

doc = docMapper.getDocumentMapper().parse(source(parser).index(index).type(type).flyweight(true));

if (context.highlight() != null) {

doc.setSource(fetchedDoc);

}

} catch (Throwable e) {

throw new ElasticsearchParseException("failed to parse request", e);

} finally {

if (parser != null) {

parser.close();

}

}

if (doc == null) {

throw new ElasticsearchParseException("No doc to percolate in the request");

}

return doc;

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:27,

示例12: parseGeometries

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

/**

* Parse the geometries array of a GeometryCollection

*

* @param parser Parser that will be read from

* @return Geometry[] geometries of the GeometryCollection

* @throws IOException Thrown if an error occurs while reading from the XContentParser

*/

protected static GeometryCollectionBuilder parseGeometries(XContentParser parser, GeoShapeFieldMapper mapper) throws

IOException {

if (parser.currentToken() != XContentParser.Token.START_ARRAY) {

throw new ElasticsearchParseException("geometries must be an array of geojson objects");

}

XContentParser.Token token = parser.nextToken();

GeometryCollectionBuilder geometryCollection = newGeometryCollection( (mapper == null) ? Orientation.RIGHT : mapper

.fieldType().orientation());

while (token != XContentParser.Token.END_ARRAY) {

ShapeBuilder shapeBuilder = GeoShapeType.parse(parser);

geometryCollection.shape(shapeBuilder);

token = parser.nextToken();

}

return geometryCollection;

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:25,

示例13: parseLineString

​點讚 3

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

protected static LineStringBuilder parseLineString(CoordinateNode coordinates) {

/**

* Per GeoJSON spec (http://geojson.org/geojson-spec.html#linestring)

* "coordinates" member must be an array of two or more positions

* LineStringBuilder should throw a graceful exception if < 2 coordinates/points are provided

*/

if (coordinates.children.size() < 2) {

throw new ElasticsearchParseException("invalid number of points in LineString (found [{}] - must be >= 2)", coordinates.children.size());

}

LineStringBuilder line = newLineString();

for (CoordinateNode node : coordinates.children) {

line.point(node.coordinate);

}

return line;

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:17,

示例14: testMatchFormatsIsMandatory

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testMatchFormatsIsMandatory() throws Exception {

DateProcessor.Factory factory = new DateProcessor.Factory();

Map config = new HashMap<>();

String sourceField = randomAsciiOfLengthBetween(1, 10);

String targetField = randomAsciiOfLengthBetween(1, 10);

config.put("field", sourceField);

config.put("target_field", targetField);

try {

factory.create(null, null, config);

fail("processor creation should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), containsString("[formats] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:16,

示例15: parseArrayToSet

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

private Set parseArrayToSet(XContentParser parser) throws IOException {

final Set set = new HashSet<>();

if (parser.currentToken() != XContentParser.Token.START_ARRAY) {

throw new ElasticsearchParseException("Missing start of array in include/exclude clause");

}

while (parser.nextToken() != XContentParser.Token.END_ARRAY) {

if (!parser.currentToken().isValue()) {

throw new ElasticsearchParseException("Array elements in include/exclude clauses should be string values");

}

set.add(new BytesRef(parser.text()));

}

return set;

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:14,

示例16: sourceAsMap

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

@SuppressWarnings({"unchecked"})

@Override

public Map sourceAsMap() throws ElasticsearchParseException {

if (source == null) {

return null;

}

if (sourceAsMap != null) {

return sourceAsMap;

}

sourceAsMap = SourceLookup.sourceAsMap(source);

return sourceAsMap;

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:14,

示例17: testCreateNoFieldPresent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNoFieldPresent() throws Exception {

Map config = new HashMap<>();

config.put("value", "value1");

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[field] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,

示例18: testCreateNoValuePresent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNoValuePresent() throws Exception {

Map config = new HashMap<>();

config.put("field", "field1");

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[value] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,

示例19: testCreateNullValue

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNullValue() throws Exception {

Map config = new HashMap<>();

config.put("field", "field1");

config.put("value", null);

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[value] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,

示例20: parse

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

@Override

public SignificanceHeuristic parse(XContentParser parser, ParseFieldMatcher parseFieldMatcher, SearchContext context)

throws IOException, QueryParsingException {

// move to the closing bracket

if (!parser.nextToken().equals(XContentParser.Token.END_OBJECT)) {

throw new ElasticsearchParseException("failed to parse [jhl] significance heuristic. expected an empty object, but found [{}] instead", parser.currentToken());

}

return new JLHScore();

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:10,

示例21: testCreateNoFieldPresent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNoFieldPresent() throws Exception {

RenameProcessor.Factory factory = new RenameProcessor.Factory();

Map config = new HashMap<>();

config.put("target_field", "new_field");

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[field] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,

示例22: testCreateNoToPresent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNoToPresent() throws Exception {

RenameProcessor.Factory factory = new RenameProcessor.Factory();

Map config = new HashMap<>();

config.put("field", "old_field");

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[target_field] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,

示例23: readParserConfigurations

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

private List> readParserConfigurations(XContentParser yamlParser) throws IOException {

List > patternList = new ArrayList<>();

XContentParser.Token token = yamlParser.nextToken();

if (token != XContentParser.Token.START_ARRAY) {

throw new ElasticsearchParseException("malformed regular expression file, should continue with 'array' after 'object'");

}

token = yamlParser.nextToken();

if (token != XContentParser.Token.START_OBJECT) {

throw new ElasticsearchParseException("malformed regular expression file, expecting 'object'");

}

while (token == XContentParser.Token.START_OBJECT) {

token = yamlParser.nextToken();

if (token != XContentParser.Token.FIELD_NAME) {

throw new ElasticsearchParseException("malformed regular expression file, should continue with 'field_name' after 'array'");

}

Map regexMap = new HashMap<>();

for (; token == XContentParser.Token.FIELD_NAME; token = yamlParser.nextToken()) {

String fieldName = yamlParser.currentName();

token = yamlParser.nextToken();

String fieldValue = yamlParser.text();

regexMap.put(fieldName, fieldValue);

}

patternList.add(regexMap);

token = yamlParser.nextToken();

}

return patternList;

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:37,

示例24: testBuildNonExistingDbFile

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testBuildNonExistingDbFile() throws Exception {

GeoIpProcessor.Factory factory = new GeoIpProcessor.Factory(databaseReaders);

Map config = new HashMap<>();

config.put("field", "_field");

config.put("database_file", "does-not-exist.mmdb.gz");

try {

factory.create(null, null, config);

fail("Exception expected");

} catch (ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[database_file] database file [does-not-exist.mmdb.gz] doesn't exist"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:14,

示例25: testCreateMissingField

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateMissingField() throws Exception {

LowercaseProcessor.Factory factory = new LowercaseProcessor.Factory();

Map config = new HashMap<>();

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[field] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,

示例26: testDateRangeQueryFormat

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testDateRangeQueryFormat() throws IOException {

assumeTrue("test runs only when at least a type is registered", getCurrentTypes().length > 0);

// We test 01/01/2012 from gte and 2030 for lt

String query = "{\n" +

" \"range\" : {\n" +

" \"" + DATE_FIELD_NAME + "\" : {\n" +

" \"gte\": \"01/01/2012\",\n" +

" \"lt\": \"2030\",\n" +

" \"format\": \"dd/MM/yyyy||yyyy\"\n" +

" }\n" +

" }\n" +

"}";

Query parsedQuery = parseQuery(query).toQuery(createShardContext());

assertThat(parsedQuery, instanceOf(IndexOrDocValuesQuery.class));

parsedQuery = ((IndexOrDocValuesQuery) parsedQuery).getIndexQuery();

assertThat(parsedQuery, instanceOf(PointRangeQuery.class));

assertEquals(LongPoint.newRangeQuery(DATE_FIELD_NAME,

DateTime.parse("2012-01-01T00:00:00.000+00").getMillis(),

DateTime.parse("2030-01-01T00:00:00.000+00").getMillis() - 1),

parsedQuery);

// Test Invalid format

final String invalidQuery = "{\n" +

" \"range\" : {\n" +

" \"" + DATE_FIELD_NAME + "\" : {\n" +

" \"gte\": \"01/01/2012\",\n" +

" \"lt\": \"2030\",\n" +

" \"format\": \"yyyy\"\n" +

" }\n" +

" }\n" +

"}";

expectThrows(ElasticsearchParseException.class, () -> parseQuery(invalidQuery).toQuery(createShardContext()));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:35,

示例27: xContent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

/**

* Guesses the content type based on the provided bytes.

*/

public static XContent xContent(byte[] data, int offset, int length) {

XContentType type = xContentType(data, offset, length);

if (type == null) {

throw new ElasticsearchParseException("Failed to derive xcontent");

}

return xContent(type);

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:11,

示例28: testBuildEmptyPatternsList

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testBuildEmptyPatternsList() throws Exception {

GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap());

Map config = new HashMap<>();

config.put("field", "foo");

config.put("patterns", Collections.emptyList());

ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));

assertThat(e.getMessage(), equalTo("[patterns] List of patterns must not be empty"));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:9,

示例29: testCreateWithInvalidPatternDefinition

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateWithInvalidPatternDefinition() throws Exception {

GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap());

Map config = new HashMap<>();

config.put("field", "_field");

config.put("patterns", Collections.singletonList("%{MY_PATTERN:name}!"));

config.put("pattern_definitions", Collections.singletonMap("MY_PATTERN", "["));

ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));

assertThat(e.getMessage(),

equalTo("[patterns] Invalid regex pattern found in: [%{MY_PATTERN:name}!]. premature end of char-class"));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,

示例30: thresholdPercentageFromWatermark

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

/**

* Attempts to parse the watermark into a percentage, returning 100.0% if

* it cannot be parsed.

*/

public double thresholdPercentageFromWatermark(String watermark) {

try {

return RatioValue.parseRatioValue(watermark).getAsPercent();

} catch (ElasticsearchParseException ex) {

// NOTE: this is not end-user leniency, since up above we check that it's a valid byte or percentage, and then store the two cases separately

return 100.0;

}

}

開發者ID:baidu,項目名稱:Elasticsearch,代碼行數:13,

示例31: testCreateWithMissingFieldSplit

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateWithMissingFieldSplit() {

KeyValueProcessor.Factory factory = new KeyValueProcessor.Factory();

Map config = new HashMap<>();

config.put("field", "field1");

String processorTag = randomAsciiOfLength(10);

ElasticsearchException exception = expectThrows(ElasticsearchParseException.class,

() -> factory.create(null, processorTag, config));

assertThat(exception.getMessage(), equalTo("[field_split] required property is missing"));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,

示例32: testCreateWithMissingValueSplit

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateWithMissingValueSplit() {

KeyValueProcessor.Factory factory = new KeyValueProcessor.Factory();

Map config = new HashMap<>();

config.put("field", "field1");

config.put("field_split", "&");

String processorTag = randomAsciiOfLength(10);

ElasticsearchException exception = expectThrows(ElasticsearchParseException.class,

() -> factory.create(null, processorTag, config));

assertThat(exception.getMessage(), equalTo("[value_split] required property is missing"));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,

示例33: testCreateNoSeparatorPresent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNoSeparatorPresent() throws Exception {

JoinProcessor.Factory factory = new JoinProcessor.Factory();

Map config = new HashMap<>();

config.put("field", "field1");

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch (ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[separator] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,

示例34: testCreateMissingField

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateMissingField() throws Exception {

UppercaseProcessor.Factory factory = new UppercaseProcessor.Factory();

Map config = new HashMap<>();

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[field] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:11,

示例35: testCreateNoFieldPresent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNoFieldPresent() throws Exception {

SplitProcessor.Factory factory = new SplitProcessor.Factory();

Map config = new HashMap<>();

config.put("separator", "\\.");

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[field] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,

示例36: xContent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

/**

* Guesses the content type based on the provided bytes and returns the corresponding {@link XContent}

*

* @deprecated guessing the content type should not be needed ideally. We should rather know the content type upfront or read it

* from headers. Till we fixed the REST layer to read the Content-Type header, that should be the only place where guessing is needed.

*/

@Deprecated

public static XContent xContent(byte[] data, int offset, int length) {

XContentType type = xContentType(data, offset, length);

if (type == null) {

throw new ElasticsearchParseException("Failed to derive xcontent");

}

return xContent(type);

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:15,

示例37: testInvalidPointLonHashMix

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testInvalidPointLonHashMix() throws IOException {

XContentBuilder content = JsonXContent.contentBuilder();

content.startObject();

content.field("lon", 0).field("geohash", stringEncode(0d, 0d));

content.endObject();

XContentParser parser = createParser(JsonXContent.jsonXContent, content.bytes());

parser.nextToken();

Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser));

assertThat(e.getMessage(), is("field must be either lat/lon or geohash"));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,

示例38: testCreateNoPatternPresent

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateNoPatternPresent() throws Exception {

GsubProcessor.Factory factory = new GsubProcessor.Factory();

Map config = new HashMap<>();

config.put("field", "field1");

config.put("replacement", "-");

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[pattern] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:13,

示例39: testParseGeoPointArrayWrongType

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testParseGeoPointArrayWrongType() throws IOException {

double lat = 0.0;

boolean lon = false;

XContentBuilder json = jsonBuilder().startObject().startArray("foo").value(lon).value(lat).endArray().endObject();

XContentParser parser = createParser(json);

while (parser.currentToken() != Token.START_ARRAY) {

parser.nextToken();

}

Exception e = expectThrows(ElasticsearchParseException.class, () -> GeoUtils.parseGeoPoint(parser));

assertThat(e.getMessage(), is("numeric value expected"));

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:12,

示例40: testCreateMissingMessageField

​點讚 2

import org.elasticsearch.ElasticsearchParseException; //導入依賴的package包/類

public void testCreateMissingMessageField() throws Exception {

Map config = new HashMap<>();

try {

factory.create(null, null, config);

fail("factory create should have failed");

} catch(ElasticsearchParseException e) {

assertThat(e.getMessage(), equalTo("[message] required property is missing"));

}

}

開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:10,

注:本文中的org.elasticsearch.ElasticsearchParseException類示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值