question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

indices client and xcontent/json support

See original GitHub issue

Hello and I have a question: I am trying out this new fluent client and have a bunch of projects that I wanted to migrate from the RHLC to the new API client. Now I am kinda stuck on an inconvenient spot, creating an index with settings and mapping. the builder and functional pattern are nice, though in our projects we put json-files for mappings and settings which are read and converted into an object/xContentBuilder so we do not have to implement complex settings/mappings into java code (and reuse without copy paste).

kinda like that

CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName)
				.settings(this.elasticsearchIndexService.createSettings(ELASTICSEARCH_INDEX_SETTINGS_FILE))
				.mapping(this.elasticsearchIndexService.createMapping(ELASTICSEARCH_INDEX_MAPPING_FILE,
					ELASTICSEARCH_INDEX_MAPPING_FOLDER, shop));
AcknowledgedResponse indexCreateResponse = this.restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT);

depending on the shop parameter different mappings are loaded.

Is there a similar and fluent way doing that in the new client or are there any plans supporting json/xcontent?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:13
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
swallezcommented, Mar 17, 2022

We’ve added support for loading JSON directly from object builders with a new withJson(someJson) method in PR #200.

This is backwards compatible and will be in the next 7.17 and 8.1 patch releases.

The documentation for this new feature is already up for the main branch.

2reactions
adagioscommented, Feb 11, 2022

(don’t think this is the right place for this, but trying to help)

@sulaukad to build a query you could use:

        WrapperQuery query = new WrapperQuery.Builder()
                .query("{some json query}")
                .build();

or in a builder:

        SearchRequest request = new SearchRequest.Builder()
                .query(_0 -> _0.wrapper(_1 -> _1
                        .query("{some json query}")))
                .build();

Read more comments on GitHub >

github_iconTop Results From Across the Web

Index API | Java Transport Client (deprecated) [7.17] - Elastic
The following example indexes a JSON document into an index called twitter, under a type called _doc , with id valued 1: import...
Read more >
I am working on ES for the first time. I am trying to upload a ...
I am creating a new index and then mapping the json data ... refer to this Elasticsearch docs for field datatype supported by...
Read more >
Connecting to an Elasticsearch cluster - Quarkus
We inject an Elasticsearch RestHighLevelClient inside the service. We create an Elasticsearch index request. We use Vert.x JsonObject to serialize the object ...
Read more >
IndexRequest - elasticsearch 7.16.1 javadoc
Index request to index a typed JSON document into a specific index and make it ... Fields inherited from class org.elasticsearch.action.support.replication.
Read more >
CreateIndexRequest.settings - Java - Tabnine
client.admin().indices().create( new CreateIndexRequest(indexKey) .settings( ... The settings to create the index with (either json/yaml/properties format) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found