Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ public String getName() {
}

/**
* Whether this field is indexed for search on all indices.
* Whether this field can be aggregated on all indices.
*/
public boolean isAggregatable() {
return isAggregatable;
}

/**
* Whether this field can be aggregated on all indices.
* Whether this field is indexed for search on all indices.
*/
public boolean isSearchable() {
return isSearchable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ public String[] fields() {
}

/**
*
* The list of indices to lookup
*/
public FieldCapabilitiesRequest indices(String... indices) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private FieldCapabilitiesResponse(Map<String, Map<String, FieldCapabilities>> re
*/
FieldCapabilitiesResponse() {
this.responseMap = Collections.emptyMap();
this.indexResponses = Collections.emptyList();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super minor nit: we say in the javadocs that this is used for serialization, but it's also used when the response is empty (totalNumRequest == 0 in TransportFieldCapabilitiesAction). Maybe we could have the transport action use one of the other constructors and provide an empty map? And maybe we should validate that what is provided is never null?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++, I pushed a605160

}

/**
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/org/elasticsearch/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ public interface Client extends ElasticsearchClient, Releasable {
/**
* Builder for the field capabilities request.
*/
FieldCapabilitiesRequestBuilder prepareFieldCaps();
FieldCapabilitiesRequestBuilder prepareFieldCaps(String... indices);

/**
* An action that returns the field capabilities from the provided request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,8 @@ public ActionFuture<FieldCapabilitiesResponse> fieldCaps(FieldCapabilitiesReques
}

@Override
public FieldCapabilitiesRequestBuilder prepareFieldCaps() {
return new FieldCapabilitiesRequestBuilder(this, FieldCapabilitiesAction.INSTANCE);
public FieldCapabilitiesRequestBuilder prepareFieldCaps(String... indices) {
return new FieldCapabilitiesRequestBuilder(this, FieldCapabilitiesAction.INSTANCE, indices);
}

static class Admin implements AdminClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,11 @@ public void testFieldAliasFilteringWithWildcard() {
assertEquals(1, response.get().size());
assertTrue(response.get().containsKey("distance"));
}

public void testEmptyIndexPattern() {
FieldCapabilitiesResponse response = client().prepareFieldCaps("empty_index_pattern*")
.setFields("*")
.execute().actionGet();
assertEquals(0, response.get().size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be done from a unit test as well right? Create the response using the default constructor and call writeTo on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I pushed a605160

}
}