How can I create a simple match query?
See original GitHub issueGoing on with my tests I wanted to create a simple match
query for a call like this:
GET /test-index/_search
{
"query": {
"match": {
"message": {
"query": "this is a test"
}
}
}
}
I try to use this code:
SearchRequest searchRequest = new SearchRequest.Builder()
.index("test-index")
.query(b -> b
.match(
// what to use here????
))
.build();
The QueryContainer.Builder
has these 2 match
methods:
public ObjectBuilder<QueryContainer> match(NamedQuery<JsonValue> v) {
this.$variant = v;
this.$tag = QueryContainer.Tag.match;
return new Constant(this.build());
}
public ObjectBuilder<QueryContainer> match(Function<co.elastic.clients.elasticsearch._types.query_dsl.NamedQuery.Builder<JsonValue>, ObjectBuilder<NamedQuery<JsonValue>>> f) {
return this.match((NamedQuery)((ObjectBuilder)f.apply(new co.elastic.clients.elasticsearch._types.query_dsl.NamedQuery.Builder())).build());
}
what would I need to put there? I am missing a MatchQuery
class here. Or something like
.match(m -> m.field("message").query("this is a test").build()
The same problem comes up when trying to build a simple terms query.
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Match query | Elasticsearch Guide [8.5] | Elastic
Returns documents that match a provided text, number, date or boolean value. The provided text is analyzed before matching. The match query is...
Read more >Create a simple select query - Microsoft Support
On the Create tab, in the Queries group, click Query Wizard. The Queries group in the Access ribbon displays two options: Query Wizard...
Read more >42 Elasticsearch Query Examples - Tutorial - Coralogix
The “match” query is one of the most basic and commonly used queries in Elasticsearch and functions as a full-text query.
Read more >Access: Designing a Simple Query - YouTube
This video includes information on: • How queries are used • Creating a simple one-table query We hope you enjoy!
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Having some reactive client would be nice; currently I have an implementation where I add reactive versions of the imperative part (if you have spare time you can look at what I did here: https://github.com/sothawo/spring-data-elasticsearch/tree/new-Elasticsearch-client/src/main/java/org/springframework/data/elasticsearch/clients/reactive/elasticsearch - still work in progress as well).
The problem is that I have to make sure that all the methods that exist in the imperative part are adapted to the reactive part. Having some base class or interface would help.
But I think that is not necessarily needed for the first version, it’s more important to have all the requests and responses available.
btw, the
RestClient
implementsCloseable
and should be closed when not used anymore. Would it make sense to makeElasticsearchClient
implementAutoCloseable
and pass a call toclose()
down to theRestClient
?I didn’t want to rush you, it just might have been that some part of the autogeneration was not executed properly although it should. So there’s no problem with that, there are still enough parts I can work on. Btw, great work, I like that concept with the
Transport
and theEndpoint
that helps a lot in building a reactive Elasticsearch Client that can reuse the code to build requests and parse responses.When this will be released we can have a great cleanup of code in Spring Data Elasticsearch, looking forward to it.
I’ll close this issue and patiently wait for the next releases.