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

[DOCS] copy_to only works one level deep, not recursively #37249

Merged
merged 1 commit into from
Jan 13, 2019
Merged

[DOCS] copy_to only works one level deep, not recursively #37249

merged 1 commit into from
Jan 13, 2019

Conversation

geekpete
Copy link
Member

@geekpete geekpete commented Jan 9, 2019

Clarify that you cannot "chain" fields with copy_to and expect it to recursively copy via intermediary fields.

@geekpete geekpete added >docs General docs changes :Search Foundations/Mapping Index mappings, including merging and defining field types labels Jan 9, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@geekpete
Copy link
Member Author

geekpete commented Jan 9, 2019

I also had an example snippet to demonstrate this scenario but thought that single bullet point describing it was enough:

# cleanup from previous test runs
DELETE my_index

# create index with copy_to for field_1->field_2, another for field_2->field_3
PUT my_index
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  }, 
  "mappings": {
    "_doc": {
      "properties": {
        "field_1": {
          "type": "text",
          "copy_to": "field_2"
        },
        "field_2": {
          "type": "text",
          "copy_to": "field_3" 
        },
        "field_3": {
          "type": "text",
          "store": true
        }
      }
    }
  }
}

# index a doc with a value in field_1
PUT my_index/_doc/1
{
  "field_1": "testing field 1"
}

# index another doc with a value in field_2
PUT my_index/_doc/2
{
  "field_2": "testing field 2"
}


# doc 1 doesn't copy the value into field_3, doc 2 does.
GET my_index/_search
{
  "stored_fields": [ "field_1","field_2","field_3" ],
  "_source": "*"
}

Resulting in:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 2,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "field_1" : "testing field 1"
        }
      },
      {
        "_index" : "my_index",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "field_2" : "testing field 2"
        },
        "fields" : {
          "field_3" : [
            "testing field 2"
          ]
        }
      }
    ]
  }
}

Copy link
Member

@cbuescher cbuescher left a comment

Choose a reason for hiding this comment

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

@geekpete thanks, LGTM. Which version do you thing this addition should be targeted at? Do you want to merge or should I do that

@geekpete
Copy link
Member Author

6.x and 7.x versions of the docs I guess would be great.
I can merge and cherry-picky to those versions.

@cbuescher
Copy link
Member

@geekpete thanks for merging, I also cherry-picked to 6.x and 6.6 since I think they were missed, or did you leave them out on purpose?

@geekpete
Copy link
Member Author

Had just missed them not left out on purpose.
Will be looking to use the backport tool by sqren next time I cherry pick across branches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>docs General docs changes :Search Foundations/Mapping Index mappings, including merging and defining field types v6.2.5 v6.3.3 v6.4.4 v6.5.5 v6.6.1 v6.7.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants