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

Support index sorting for unsigned_long/half_float/scaled_float #72741

Open
hendrikmuhs opened this issue May 5, 2021 · 4 comments
Open

Support index sorting for unsigned_long/half_float/scaled_float #72741

hendrikmuhs opened this issue May 5, 2021 · 4 comments
Labels

Comments

@hendrikmuhs
Copy link
Contributor

Index sort claims to support numeric fields, however, when trying to apply index sort to unsigned_long, but also half_ and scaled_ float, the API returns an IAE.

Repro:

PUT index
{
  "settings": {
    "index": {
      "number_of_shards": 5,
      "sort.field": [
        "timestamp",
        "metric"
      ],
      "sort.order": [
        "desc",
        "desc"
      ],
      "sort.missing": [
        "_first",
        "_last"
      ]
    }
  },
  "mappings": {
    "properties": {
      "timestamp": {
        "type": "date"
      },
      "metric": {
        "type": "unsigned_long"
      }
    }
  }
}

returns

{
  "error" : {
    "root_cause" : [
      {
        "type" : "illegal_argument_exception",
        "reason" : "invalid index sort field:[metric]"
      }
    ],
    "type" : "illegal_argument_exception",
    "reason" : "invalid index sort field:[metric]"
  },
  "status" : 400
}

Note: This might be by design, however

  • the returned error lacks a proper message
  • documentation should exclude the mentioned data types

It would be good to fix ^ as short term solution.

@hendrikmuhs hendrikmuhs added >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types labels May 5, 2021
@elasticmachine elasticmachine added the Team:Search Meta label for search team label May 5, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (Team:Search)

@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-storage-engine (Team:StorageEngine)

@elasticsearchmachine elasticsearchmachine removed the Team:Search Meta label for search team label May 31, 2024
@martijnvg
Copy link
Member

Note that this is still an issue for half_float and scaled_float. The problem was only fixed for unsigned_long by #75599.

Stacktrace:

[2024-06-21T11:36:44,223][INFO ][o.e.c.m.MetadataCreateIndexService] [runTask-0] failed on parsing mappings on index creation [index1] java.lang.IllegalArgumentException: invalid index sort field:[metric]
        at [email protected]/org.elasticsearch.index.IndexSortConfig.validateIndexSortField(IndexSortConfig.java:282)
        at [email protected]/org.elasticsearch.index.IndexSortConfig.buildIndexSort(IndexSortConfig.java:274)
        at [email protected]/org.elasticsearch.index.IndexService.lambda$new$2(IndexService.java:235)
        at [email protected]/org.elasticsearch.cluster.metadata.MetadataCreateIndexService.updateIndexMappingsAndBuildSortOrder(MetadataCreateIndexService.java:1351)
        at [email protected]/org.elasticsearch.cluster.metadata.MetadataCreateIndexService.lambda$applyCreateIndexWithTemporaryService$2(MetadataCreateIndexService.java:473)
        at [email protected]/org.elasticsearch.indices.IndicesService.withTempIndexService(IndicesService.java:718)
        at [email protected]/org.elasticsearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexWithTemporaryService(MetadataCreateIndexService.java:471)
        at [email protected]/org.elasticsearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexRequestWithV1Templates(MetadataCreateIndexService.java:594)
        at [email protected]/org.elasticsearch.cluster.metadata.MetadataCreateIndexService.applyCreateIndexRequest(MetadataCreateIndexService.java:421)
        at [email protected]/org.elasticsearch.cluster.metadata.MetadataCreateIndexService$1.execute(MetadataCreateIndexService.java:300)
        at [email protected]/org.elasticsearch.cluster.service.MasterService$UnbatchedExecutor.execute(MasterService.java:569)
        at [email protected]/org.elasticsearch.cluster.service.MasterService.innerExecuteTasks(MasterService.java:1070)
        at [email protected]/org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:1033)
        at [email protected]/org.elasticsearch.cluster.service.MasterService.executeAndPublishBatch(MasterService.java:233)
        at [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.lambda$run$2(MasterService.java:1686)
        at [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:444)
        at [email protected]/org.elasticsearch.cluster.service.MasterService$BatchingTaskQueue$Processor.run(MasterService.java:1683)
        at [email protected]/org.elasticsearch.cluster.service.MasterService$5.lambda$doRun$0(MasterService.java:1278)
        at [email protected]/org.elasticsearch.action.ActionListener.run(ActionListener.java:444)
        at [email protected]/org.elasticsearch.cluster.service.MasterService$5.doRun(MasterService.java:1257)
        at [email protected]/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:984)
        at [email protected]/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1570)

@lkts
Copy link
Contributor

lkts commented Jun 21, 2024

So it fails since the sort type is CUSTOM and it is not here:

private static final EnumSet<SortField.Type> ALLOWED_INDEX_SORT_TYPES = EnumSet.of(

I can't tell if it's intentional. It seems like FloatValuesComparatorSource should be able to handle half_float values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants