Search in sources :

Example 86 with ElasticsearchParseException

use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.

the class AttachmentProcessorTests method testEncryptedPdf.

public void testEncryptedPdf() throws Exception {
    ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> parseDocument("encrypted.pdf", processor));
    assertThat(e.getDetailedMessage(), containsString("document is encrypted"));
}
Also used : ElasticsearchParseException(org.elasticsearch.ElasticsearchParseException)

Example 87 with ElasticsearchParseException

use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.

the class GeoIpProcessor method execute.

@Override
public void execute(IngestDocument ingestDocument) {
    String ip = ingestDocument.getFieldValue(field, String.class, ignoreMissing);
    if (ip == null && ignoreMissing) {
        return;
    } else if (ip == null) {
        throw new IllegalArgumentException("field [" + field + "] is null, cannot extract geoip information.");
    }
    final InetAddress ipAddress = InetAddresses.forString(ip);
    Map<String, Object> geoData;
    switch(dbReader.getMetadata().getDatabaseType()) {
        case CITY_DB_TYPE:
            try {
                geoData = retrieveCityGeoData(ipAddress);
            } catch (AddressNotFoundRuntimeException e) {
                geoData = Collections.emptyMap();
            }
            break;
        case COUNTRY_DB_TYPE:
            try {
                geoData = retrieveCountryGeoData(ipAddress);
            } catch (AddressNotFoundRuntimeException e) {
                geoData = Collections.emptyMap();
            }
            break;
        default:
            throw new ElasticsearchParseException("Unsupported database type [" + dbReader.getMetadata().getDatabaseType() + "]", new IllegalStateException());
    }
    if (geoData.isEmpty() == false) {
        ingestDocument.setFieldValue(targetField, geoData);
    }
}
Also used : ElasticsearchParseException(org.elasticsearch.ElasticsearchParseException) InetAddress(java.net.InetAddress)

Example 88 with ElasticsearchParseException

use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.

the class UserAgentProcessorFactoryTests method testInvalidPropertiesType.

public void testInvalidPropertiesType() throws Exception {
    UserAgentProcessor.Factory factory = new UserAgentProcessor.Factory(userAgentParsers);
    Map<String, Object> config = new HashMap<>();
    config.put("field", "_field");
    config.put("properties", "invalid");
    ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));
    assertThat(e.getMessage(), equalTo("[properties] property isn't a list, but of type [java.lang.String]"));
}
Also used : HashMap(java.util.HashMap) ElasticsearchParseException(org.elasticsearch.ElasticsearchParseException)

Example 89 with ElasticsearchParseException

use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.

the class UserAgentProcessorFactoryTests method testInvalidProperty.

public void testInvalidProperty() throws Exception {
    UserAgentProcessor.Factory factory = new UserAgentProcessor.Factory(userAgentParsers);
    Map<String, Object> config = new HashMap<>();
    config.put("field", "_field");
    config.put("properties", Collections.singletonList("invalid"));
    ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));
    assertThat(e.getMessage(), equalTo("[properties] illegal property value [invalid]. valid values are [NAME, MAJOR, MINOR, " + "PATCH, OS, OS_NAME, OS_MAJOR, OS_MINOR, DEVICE, BUILD]"));
}
Also used : HashMap(java.util.HashMap) ElasticsearchParseException(org.elasticsearch.ElasticsearchParseException)

Example 90 with ElasticsearchParseException

use of org.elasticsearch.ElasticsearchParseException in project elasticsearch by elastic.

the class UserAgentProcessorFactoryTests method testBuildNonExistingRegexFile.

public void testBuildNonExistingRegexFile() throws Exception {
    UserAgentProcessor.Factory factory = new UserAgentProcessor.Factory(userAgentParsers);
    Map<String, Object> config = new HashMap<>();
    config.put("field", "_field");
    config.put("regex_file", "does-not-exist.yaml");
    ElasticsearchParseException e = expectThrows(ElasticsearchParseException.class, () -> factory.create(null, null, config));
    assertThat(e.getMessage(), equalTo("[regex_file] regex file [does-not-exist.yaml] doesn't exist (has to exist at node startup)"));
}
Also used : HashMap(java.util.HashMap) ElasticsearchParseException(org.elasticsearch.ElasticsearchParseException)

Aggregations

ElasticsearchParseException (org.elasticsearch.ElasticsearchParseException)106 XContentParser (org.elasticsearch.common.xcontent.XContentParser)44 HashMap (java.util.HashMap)28 ArrayList (java.util.ArrayList)18 IOException (java.io.IOException)13 Map (java.util.Map)11 List (java.util.List)7 GeoPoint (org.elasticsearch.common.geo.GeoPoint)7 XContentBuilder (org.elasticsearch.common.xcontent.XContentBuilder)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 ParsingException (org.elasticsearch.common.ParsingException)5 HashSet (java.util.HashSet)4 Set (java.util.Set)4 ElasticsearchTimeoutException (org.elasticsearch.ElasticsearchTimeoutException)4 Version (org.elasticsearch.Version)4 NoNodeAvailableException (org.elasticsearch.client.transport.NoNodeAvailableException)4 IndexMetaData (org.elasticsearch.cluster.metadata.IndexMetaData)4 UncheckedIOException (java.io.UncheckedIOException)3 LinkedHashSet (java.util.LinkedHashSet)3 PutPipelineRequest (org.elasticsearch.action.ingest.PutPipelineRequest)3