Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

copy_to of metadata field isn't working (v3.0.2) #190

Closed
gpaul opened this issue Nov 17, 2015 · 6 comments
Closed

copy_to of metadata field isn't working (v3.0.2) #190

gpaul opened this issue Nov 17, 2015 · 6 comments
Labels

Comments

@gpaul
Copy link

gpaul commented Nov 17, 2015

The following set of steps against a fresh elasticsearch 2.0.0 instance with v3.0.2 of this plugin installed shows that copy_to isn't working for the name field. I doubt it is working for the other metadata fields, either.

You can copy/paste this in your shell.

# create a mapping
curl -XPOST 'http://localhost:9200/test_copyto' -d '{
  "mappings": {
    "person": {
      "properties": {
        "copy_dst": { "type": "string" },
        "doc": {
      "type": "attachment",
      "fields": {
        "name": { "copy_to": "copy_dst" }
          }
    }
      }
    }
  }
}'
## => {"acknowledged":true}


# index a document, specifying a document name
curl -XPOST 'http://localhost:9200/test_copyto/person/1' -d '{
  "doc": {
    "_content": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=",
    "_name": "my-attachment-name.doc"
  }
}'
## => {"_index":"test_copyto","_type":"person","_id":"1","_version":1,"_shards":{"total":2,"successful":1,"failed":0},"created":true}


# search for the document by its contents
curl -XPOST 'http://localhost:9200/test_copyto/person/_search' -d '
{
  "query": {
    "query_string": {
      "default_field": "doc.content",
      "fields": ["copy_dst", "doc.content"],
      "query": "ipsum"
    }
  }
}
'
## => {"took":5,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits": "total":1,"max_score":0.04119441,"hits":[{"_index":"test_copyto","_type":"person","_id":"1","_score":0.04119441,"_source":{
#  "doc": {
#    "_content": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=",
#    "_name": "my-attachment-name.doc"
#  }
#}}]}}


# search for the document by its name
curl -XPOST 'http://localhost:9200/test_copyto/person/_search' -d '
{
  "query": {
    "query_string": {
      "default_field": "doc.name",
      "fields": ["doc.name"],
      "query": "my-test.doc"
    }
  }
}
'
## => {"took":5,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.02250402,"hits":[{"_index":"test_copyto","_type":"person","_id":"1","_score":0.02250402,"_source":{
#  "doc": {
#    "_content": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=",
#    "_name": "my-attachment-name.doc"
#  }
#}}]}}

# search for the document by the copy_dst field
curl -XPOST 'http://localhost:9200/test_copyto/person/_search' -d '
{
  "query": {
    "query_string": {
      "default_field": "copy_dst",
      "fields": ["copy_dst"],
      "query": "my-test.doc"
    }
  }
}
'
## => {"took":1,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}
@gpaul
Copy link
Author

gpaul commented Nov 23, 2015

Ping. Should I open this issue against the main elasticsearch repository now that this plugin is moving there?

@dadoonet
Copy link
Member

Did you try the same script with elasticsearch 1.7? I'd like to know if it's a regression or if it has always been there.

I know that copy_to feature is supposed to work for the extracted text but I don't think it worked for metadata.

If I'm right (so it's not an issue but more a feature request), then you can open it in elasticsearch repo.
If I'm wrong (so it's a regression), then keep it here.

@gpaul
Copy link
Author

gpaul commented Nov 23, 2015

It seems like a regression:
elasticsearch 1.7.0 with mapper-attachments 2.7.1
yields

curl -XPOST 'http://localhost:9200/test_copyto/person/_search' -d '
 {
   "query": {
     "query_string": {
       "default_field": "copy_dst",
       "fields": ["copy_dst"],
       "query": "my-test.doc"
     }
   }
 }
 '
#{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.02250402,"hits":[{"_index":"test_copyto","_type":"person","_id":"1","_score":0.02250402,"_source":{
#  "doc": {
#    "_content": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0=",
#    "_name": "my-test.doc"
#  }
#}}]}}

@dadoonet dadoonet added the bug label Nov 23, 2015
@dadoonet
Copy link
Member

Thank you @gpaul

@htuscher
Copy link

It's also not working with the .content field

dadoonet added a commit that referenced this issue Nov 23, 2015
It's totally commented as it is failing from 2.0.

Related to #190

(cherry picked from commit 30aeda6)
dadoonet added a commit that referenced this issue Nov 23, 2015
dadoonet added a commit that referenced this issue Nov 23, 2015
It's totally commented as it is failing from 2.0.

Related to #190
@dadoonet
Copy link
Member

This issue was moved to elastic/elasticsearch#14946

dadoonet added a commit that referenced this issue Nov 23, 2015
dadoonet added a commit that referenced this issue Nov 26, 2015
dadoonet added a commit that referenced this issue Nov 26, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants