Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_field_caps API fails to return results for an index that contains a rank_feature field #44330

Closed
astefan opened this issue Jul 15, 2019 · 3 comments
Labels
>bug :Search/Mapping Index mappings, including merging and defining field types

Comments

@astefan
Copy link
Contributor

astefan commented Jul 15, 2019

For a simple index containing a rank_feature field in its mappings:

{ "mappings": { "properties": { "branches": { "type": "keyword" }, "rank" : { "type": "rank_feature" }}}}

the call to _field_caps (/_field_caps?fields=*) fails silently and responds with

{
    "indices": [
        "test"
    ],
    "fields": {}
}

but, upon close inspection and debugging, the following error is getting thrown when trying to establish if the rank field is aggregatable:

[elasticsearch] org.elasticsearch.transport.RemoteTransportException: [node-0][127.0.0.1:9300][indices:data/read/field_caps[index][s]]
[elasticsearch] Caused by: java.lang.UnsupportedOperationException: [rank_feature] fields do not support sorting, scripting or aggregating
[elasticsearch]         at org.elasticsearch.index.mapper.RankFeatureFieldMapper$RankFeatureFieldType.fielddataBuilder(RankFeatureFieldMapper.java:167) ~[?:?]
[elasticsearch]         at org.elasticsearch.index.mapper.MappedFieldType.isAggregatable(MappedFieldType.java:303) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesIndexAction.shardOperation(TransportFieldCapabilitiesIndexAction.java:92) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesIndexAction.shardOperation(TransportFieldCapabilitiesIndexAction.java:47) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.action.support.single.shard.TransportSingleShardAction$1.doRun(TransportSingleShardAction.java:112) ~[elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:769) [elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-8.0.0-SNAPSHOT.jar:8.0.0-SNAPSHOT]
[elasticsearch]         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
[elasticsearch]         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
[elasticsearch]         at java.lang.Thread.run(Thread.java:834) [?:?]

It seems the fielddataBuilder(String fullyQualifiedIndexName) method throws an UnsupportedOperationException while MappedFieldTypes isAggregatable() method catches an IllegalArgumentException when calling fielddataBuilder(). Should isAggregatable deal with UnsupportedOperationExceptions, as well, or fielddataBuidler should have a different logic?

This is related to #44320 where the above failure makes SQL to be unable to execute a simple query.

@astefan astefan added >bug :Search/Mapping Index mappings, including merging and defining field types labels Jul 15, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@jtibshirani
Copy link
Contributor

I merged #44370 to address the bug. The solution we went with changed fielddataBuilder to throw IllegalArgumentException to be consistent with the method contract.

@acbox
Copy link

acbox commented Jul 24, 2019

FYI I hit this bug after upgrading ELK stack to 7.x, the _field_caps API is used by Kibana to create index patterns. It results in all non-default fields for an index containing a single rank_feature field being stripped from the index pattern and thus not being searchable in Kibana.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Mapping Index mappings, including merging and defining field types
Projects
None yet
Development

No branches or pull requests

4 participants