Skip to content

How can I create a simple match query? #8

@sothawo

Description

@sothawo

Going 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions