org.elasticsearch.ElasticsearchGenerationException Java Examples
The following examples show how to use
org.elasticsearch.ElasticsearchGenerationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticsearchDataHandler.java From arctic-sea with Apache License 2.0 | 6 votes |
@Override public IndexResponse persist(Map<String, Object> dataMap) throws ElasticsearchGenerationException, IOException { if (!settings.isLoggingEnabled()) { return null; } if (adminHandler.getElasticsearchClient() == null) { throw new NullPointerException("Client is not initialized. Data will not be persisted."); } dataMap.put(ServiceEventDataMapping.TIMESTAMP_FIELD.getName(), DateTime.now(DateTimeZone.UTC)); dataMap.put(ServiceEventDataMapping.UUID_FIELD.getName(), settings.getUuid()); logger.debug("Persisting {}", dataMap); IndexResponse response = adminHandler.getElasticsearchClient().index( new IndexRequest(settings.getIndexId()).type(settings.getTypeId()).source(dataMap), RequestOptions.DEFAULT); return response; }
Example #2
Source File: Alias.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** * Associates a filter to the alias */ public Alias filter(QueryBuilder filterBuilder) { if (filterBuilder == null) { this.filter = null; return this; } try { XContentBuilder builder = XContentFactory.jsonBuilder(); filterBuilder.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.close(); this.filter = builder.string(); return this; } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to build json for alias request", e); } }
Example #3
Source File: CreateIndexRequest.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** * Adds mapping that will be added when the index gets created. * * @param type The mapping type * @param source The mapping source */ @SuppressWarnings("unchecked") public CreateIndexRequest mapping(String type, Map source) { if (mappings.containsKey(type)) { throw new IllegalStateException("mappings for type \"" + type + "\" were already defined"); } // wrap it in a type map if its not if (source.size() != 1 || !source.containsKey(type)) { source = MapBuilder.<String, Object>newMapBuilder().put(type, source).map(); } try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); return mapping(type, builder.string()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } }
Example #4
Source File: CreateIndexRequest.java From crate with Apache License 2.0 | 6 votes |
/** * Adds mapping that will be added when the index gets created. * * @param type The mapping type * @param source The mapping source */ @SuppressWarnings("unchecked") public CreateIndexRequest mapping(String type, Map source) { if (mappings.containsKey(type)) { throw new IllegalStateException("mappings for type \"" + type + "\" were already defined"); } // wrap it in a type map if its not if (source.size() != 1 || !source.containsKey(type)) { source = MapBuilder.<String, Object>newMapBuilder().put(type, source).map(); } try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); return mapping(type, builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } }
Example #5
Source File: CreateSnapshotRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Sets repository-specific snapshot settings. * <p> * See repository documentation for more information. * * @param source repository-specific snapshot settings * @return this request */ public CreateSnapshotRequest settings(Map<String, Object> source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(builder.string()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #6
Source File: CreateSnapshotRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets repository-specific snapshot settings. * <p> * See repository documentation for more information. * * @param source repository-specific snapshot settings * @return this request */ public CreateSnapshotRequest settings(Map<String, Object> source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(Strings.toString(builder), builder.contentType()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #7
Source File: PercolateRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Raw version of {@link #source(PercolateSourceBuilder)} */ @SuppressWarnings("unchecked") public PercolateRequest source(Map document, XContentType contentType) throws ElasticsearchGenerationException { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.map(document); return source(builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + document + "]", e); } }
Example #8
Source File: PercolateSourceBuilder.java From Elasticsearch with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public DocBuilder setDoc(Map doc, XContentType contentType) { try { return setDoc(XContentFactory.contentBuilder(contentType).map(doc)); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + doc + "]", e); } }
Example #9
Source File: IndexRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
public IndexRequest source(String field1, Object value1) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).endObject(); return source(builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate", e); } }
Example #10
Source File: IndexRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
public IndexRequest source(String field1, Object value1, String field2, Object value2) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).field(field2, value2).endObject(); return source(builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate", e); } }
Example #11
Source File: IndexRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).field(field2, value2).field(field3, value3).endObject(); return source(builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate", e); } }
Example #12
Source File: IndexRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
public IndexRequest source(String field1, Object value1, String field2, Object value2, String field3, Object value3, String field4, Object value4) { try { XContentBuilder builder = XContentFactory.contentBuilder(contentType); builder.startObject().field(field1, value1).field(field2, value2).field(field3, value3).field(field4, value4).endObject(); return source(builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate", e); } }
Example #13
Source File: AtomicArray.java From crate with Apache License 2.0 | 5 votes |
/** * Copies the content of the underlying atomic array to a normal one. */ public E[] toArray(E[] a) { if (a.length != array.length()) { throw new ElasticsearchGenerationException("AtomicArrays can only be copied to arrays of the same size"); } for (int i = 0; i < array.length(); i++) { a[i] = array.get(i); } return a; }
Example #14
Source File: PutMappingRequest.java From crate with Apache License 2.0 | 5 votes |
/** * The mapping source definition. */ @SuppressWarnings("unchecked") public PutMappingRequest source(Map mappingSource) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(mappingSource); return source(Strings.toString(builder), XContentType.JSON); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + mappingSource + "]", e); } }
Example #15
Source File: CreateIndexRequest.java From crate with Apache License 2.0 | 5 votes |
/** * The settings to create the index with (either json/yaml/properties format) */ @SuppressWarnings("unchecked") public CreateIndexRequest settings(Map source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(Strings.toString(builder), XContentType.JSON); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #16
Source File: CreateIndexRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets the aliases that will be associated with the index when it gets created */ @SuppressWarnings("unchecked") public CreateIndexRequest aliases(Map source) { try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.map(source); return aliases(BytesReference.bytes(builder)); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } }
Example #17
Source File: PutIndexTemplateRequest.java From crate with Apache License 2.0 | 5 votes |
/** * The settings to create the index template with (either json or yaml format). */ public PutIndexTemplateRequest settings(Map<String, Object> source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(Strings.toString(builder), XContentType.JSON); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #18
Source File: PutIndexTemplateRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Adds mapping that will be added when the index gets created. * * @param type The mapping type * @param source The mapping source */ public PutIndexTemplateRequest mapping(String type, Map<String, Object> source) { // wrap it in a type map if its not if (source.size() != 1 || !source.containsKey(type)) { source = MapBuilder.<String, Object>newMapBuilder().put(type, source).map(); } try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); return mapping(type, builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } }
Example #19
Source File: PutIndexTemplateRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets the aliases that will be associated with the index when it gets created */ @SuppressWarnings("unchecked") public PutIndexTemplateRequest aliases(Map source) { try { XContentBuilder builder = XContentFactory.jsonBuilder(); builder.map(source); return aliases(BytesReference.bytes(builder)); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } }
Example #20
Source File: UpdateSettingsRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets the settings to be updated (either json or yaml format) */ @SuppressWarnings("unchecked") public UpdateSettingsRequest settings(Map source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(Strings.toString(builder), builder.contentType()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #21
Source File: PutRepositoryRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets the repository settings. * * @param source repository settings * @return this request */ public PutRepositoryRequest settings(Map<String, Object> source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(Strings.toString(builder), builder.contentType()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #22
Source File: ClusterUpdateSettingsRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets the transient settings to be updated. They will not survive a full cluster restart */ @SuppressWarnings({"unchecked", "rawtypes"}) public ClusterUpdateSettingsRequest transientSettings(Map source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); transientSettings(Strings.toString(builder), builder.contentType()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #23
Source File: ClusterUpdateSettingsRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets the persistent settings to be updated. They will get applied cross restarts */ @SuppressWarnings({"unchecked", "rawtypes"}) public ClusterUpdateSettingsRequest persistentSettings(Map source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); persistentSettings(Strings.toString(builder), builder.contentType()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #24
Source File: RestoreSnapshotRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets repository-specific restore settings * <p> * See repository documentation for more information. * * @param source repository-specific snapshot settings * @return this request */ public RestoreSnapshotRequest settings(Map<String, Object> source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(Strings.toString(builder), builder.contentType()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #25
Source File: RestoreSnapshotRequest.java From crate with Apache License 2.0 | 5 votes |
/** * Sets settings that should be added/changed in all restored indices */ public RestoreSnapshotRequest indexSettings(Map<String, Object> source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); indexSettings(Strings.toString(builder), builder.contentType()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #26
Source File: RestoreSnapshotRequest.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Sets repository-specific restore settings * <p> * See repository documentation for more information. * * @param source repository-specific snapshot settings * @return this request */ public RestoreSnapshotRequest settings(Map<String, Object> source) { try { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); builder.map(source); settings(builder.string()); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + source + "]", e); } return this; }
Example #27
Source File: ElasticSearchDataHandlerIT.java From arctic-sea with Apache License 2.0 | 5 votes |
@Test public void persistBasicData() throws InterruptedException, ElasticsearchGenerationException, IOException { Thread.sleep(2500); Map<String, Object> data = new HashMap<>(); data.put("alma", "korte"); dataHandler.persist(data); logger.debug("Waiting 3s"); Thread.sleep(2500); SearchResponse response = getEmbeddedClient().search( new SearchRequest(clientSettings.getIndexId()).types(clientSettings.getTypeId()), RequestOptions.DEFAULT); Assertions.assertEquals("korte", response.getHits().getHits()[0].getSourceAsMap().get("alma")); }
Example #28
Source File: AggregationBuilder.java From Elasticsearch with Apache License 2.0 | 5 votes |
/** * Sets a raw (xcontent / json) sub addAggregation. */ public B subAggregation(Map<String, Object> aggs) { try { XContentBuilder builder = XContentFactory.contentBuilder(Requests.CONTENT_TYPE); builder.map(aggs); return subAggregation(builder); } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to generate [" + aggs + "]", e); } }
Example #29
Source File: MapperService.java From Elasticsearch with Apache License 2.0 | 5 votes |
public DocumentMapper merge(String type, CompressedXContent mappingSource, MergeReason reason, boolean updateAllTypes, boolean reindex, long mappingVersion) { if (DEFAULT_MAPPING.equals(type)) { // verify we can parse it // NOTE: never apply the default here DocumentMapper mapper = documentParser.parse(type, mappingSource); // still add it as a document mapper so we have it registered and, for example, persisted back into // the cluster meta data if needed, or checked for existence synchronized (this) { mappers = newMapBuilder(mappers).put(type, mapper).map(); } try { defaultMappingSource = mappingSource.string(); } catch (IOException e) { throw new ElasticsearchGenerationException("failed to un-compress", e); } return mapper; } else { synchronized (this) { final boolean applyDefault = // the default was already applied if we are recovering reason != MergeReason.MAPPING_RECOVERY // only apply the default mapping if we don't have the type yet && mappers.containsKey(type) == false; DocumentMapper mergeWith = parse(type, mappingSource, applyDefault); return merge(mergeWith, reason, updateAllTypes, reindex, mappingVersion); } } }
Example #30
Source File: AliasAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
public AliasAction filter(QueryBuilder queryBuilder) { if (queryBuilder == null) { this.filter = null; return this; } try { XContentBuilder builder = XContentFactory.jsonBuilder(); queryBuilder.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.close(); this.filter = builder.string(); return this; } catch (IOException e) { throw new ElasticsearchGenerationException("Failed to build json for alias request", e); } }