- 
                Notifications
    You must be signed in to change notification settings 
- Fork 25.6k
Closed
Labels
:Search Foundations/MappingIndex mappings, including merging and defining field typesIndex mappings, including merging and defining field types>enhancementTeam:Deployment ManagementMeta label for Management Experience - Deployment Management teamMeta label for Management Experience - Deployment Management teamTeam:Search FoundationsMeta label for the Search Foundations team in ElasticsearchMeta label for the Search Foundations team in Elasticsearch
Description
Describe the feature:
Provide dedicated types to index and query against semantic versions with a semver and a semver_range type.
Use of Semantic Versioning is so widespread that a dedicated semver type and semver_range type will be useful primitives to add to Elasticsearch for varied use cases.
### semantic version type and semantic version range type example usage
PUT /semver-test
{
  "mappings": {
    "properties": {
      "message": "text",
      "version": {
        "type": "semver"
      },
      "compatible_versions": {
        "type": "semver_range"
      }
    }
  }
}
# example app1
POST /semver-test/_doc/1
{
  "app": "coolapp-ce",
  "version": "1.3.2",
  "compatible_versions": {
    "gte" : "1.0.0",
    "lte" : "1.4.0"
  }
}
# example app2
POST /semver-test/_doc/1
{
  "app": "coolapp-TNG",
  "version": "6.1.9",
  "compatible_versions": {
    "gte" : "6.0.0-alpha1",
    "lt" : "6.2.0"
  }
}
# example app3
POST /semver-test/_doc/1
{
  "app": "coolapp-final",
  "version": "6.2.1",
  "compatible_versions": {
    "gte" : "6.2.0-alpha1",
    "lt" : "6.3.0"
  }
}
# semver range query
GET /semver-test/_search
{
    "query": {
        "range" : {
            "version" : {
                "gte" : "6",
                "lte" : "6.2.0"
            }
        }
    }
}
# query against semver range type
GET /semver-test/_search
{
  "query": {
    "term": {
      "compatible_versions": {
        "value": "6.2.0-beta3"
      }
    }
  }
}
More advanced range combinations might be interesting to implement such as how Python's pip tool allows versions to be specified:
https://www.python.org/dev/peps/pep-0440/#version-specifiers
bczifra, chason, ejsmith, niemyjski, rudolf and 4 morewebmat, rw-access, afharo, ebeahan, fredeil and 1 more
Metadata
Metadata
Assignees
Labels
:Search Foundations/MappingIndex mappings, including merging and defining field typesIndex mappings, including merging and defining field types>enhancementTeam:Deployment ManagementMeta label for Management Experience - Deployment Management teamMeta label for Management Experience - Deployment Management teamTeam:Search FoundationsMeta label for the Search Foundations team in ElasticsearchMeta label for the Search Foundations team in Elasticsearch