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

Upgrading mappings which uses index_name and path #11079

Closed
clintongormley opened this issue May 9, 2015 · 2 comments
Closed

Upgrading mappings which uses index_name and path #11079

clintongormley opened this issue May 9, 2015 · 2 comments
Assignees
Labels
discuss >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch

Comments

@clintongormley
Copy link
Contributor

In 2.0, I think we can upgrade the mapping in a way that is not perfect, but will cover most use cases and help users to upgrade without reindexing.

index_name and path are used for two main purposes:

  • the old way to do copy_to
  • provide fieldname aliases, eg tag points to tags

We can't distinguish between these two use cases automatically, but we can handle the first use case gracefully, and the second use case is an easy change to make application side (ie just change all use of tags to tag in searches)

A mapping that looks like this (with path set to just_name):

{
  "mappings": {
    "test": {
      "properties": {
        "name": {
          "type": "object",
          "path": "just_name", 
          "properties": {
            "first": {
              "type": "string",
              "index_name": "fullname"
            },
            "last": {
              "type": "string",
              "index_name": "fullname"
            }
          }
        }
      }
    }
  }
}

could be rewritten to:

{
  "mappings": {
    "test": {
      "properties": {
        "fullname": {
          "type": "string"
        },
        "name": {
          "type": "object",
          "properties": {
            "first": {
              "index": "no",
              "copy_to": "fullname"
            },
            "last": {
              "index": "no",
              "copy_to": "fullname"
            }
          }
        }
      }
    }
  }
}

The mapping for the new fullname field can just be the same as the mapping of the first field which uses index_name (without the index_name) setting. The original field will not be indexed (or searchable).

In the case where path is set to full, the same rules apply, but the new field uses the full path name, ie this:

{
  "mappings": {
    "test": {
      "properties": {
        "name": {
          "type": "object",
          "path": "full", 
          "properties": {
            "first": {
              "type": "string",
              "index_name": "fullname"
            },
            "last": {
              "type": "string",
              "index_name": "fullname"
            }
          }
        }
      }
    }
  }
}

could be rewritten as:

{
  "mappings": {
    "test": {
      "properties": {
        "name": {
          "type": "object",
          "properties": {
            "first": {
              "index": "no",
              "copy_to": "name.fullname"
            },
            "last": {
              "index": "no",
              "copy_to": "name.fullname"
            },
            "fullname": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}
@clintongormley clintongormley added >enhancement discuss :Search Foundations/Mapping Index mappings, including merging and defining field types labels May 9, 2015
@clintongormley
Copy link
Contributor Author

As of #9570, we maintain the old index_name and path settings on old indices. Should we do this mapping upgrade instead? If so, in 2.0 or 3.0 (when we remove bwc support)?

Personally, I think we should do it for 2.0 and warn about the change in the migration plugin (#10214)

cdgraff added a commit to cdgraff/StreamMachine that referenced this issue Dec 11, 2015
Update Schema creation to be compatible with ES > 2, index_name was deprecated and give error.
Reference: elastic/elasticsearch#11079
@clintongormley
Copy link
Contributor Author

Won't fix. Closing

@javanna javanna added the Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Foundations Meta label for the Search Foundations team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

3 participants