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

[Doc] copy_to using attachment field type #97

Closed
istvano opened this issue Jan 21, 2015 · 4 comments
Closed

[Doc] copy_to using attachment field type #97

istvano opened this issue Jan 21, 2015 · 4 comments
Assignees
Milestone

Comments

@istvano
Copy link

istvano commented Jan 21, 2015

Hi,

I am using ES 1.4 with the latest version of the mapper plugin. It is brilliant!

I have a very simple attachment field declared the following way.

"attachment" : {
    "type" : "attachment",
    "index" : "analyzed",
    "index_analyzer" : "english_analyzer",
    "search_analyzer" : "english_analyzer",
    "copy_to": "exact"
},              
"exact" : {
    "type" : "attachment",
    "index" : "analyzed",
    "index_analyzer" : "simplyfied_analyzer",
    "search_analyzer" : "simplyfied_analyzer"
}

I have two questions.

a, I does not seem to honor the copy_to command.
b. I do need to index the attachment with two different analyzer. As I need the RAW content of the file as well as stemmed version of it.

Is there an easier way to achieve this ? As ES does not seem to copy the attachment to exact and also ES seem to be ignoring my index and search analyser on both fields as well.

The documentation does not seem to be clear to me on where I need to configure the analyzer for a given attachment field.

Thanks for any clues !

@dadoonet
Copy link
Member

Interesting. I never tested the copy_to feature with plugin. I guess it does not work on a top level attachment field (file) but is only supported with an inner field (file.file).

I need to test it and I think to either support it on the top level field or document this.

You can also have a look at this commit message: ad986eb

It describes how to generate a "sub-field" file.file.store with different analysis settings. In that case we store the sub field but you could change the analyzer.

@dadoonet dadoonet self-assigned this Jan 22, 2015
@istvano
Copy link
Author

istvano commented Jan 22, 2015

Hi,

Thanks a lot for giving me the right pointer! Please do check on the sub-field as well I tried that and did not copy the content to an other sub-field either.

@dadoonet
Copy link
Member

I just checked and indeed copy_to does not really work as we could expect.

The workaround today is to define copy_to within a sub field:

{
  "person": {
    "properties": {
      "file": {
        "type": "attachment",
        "path": "full",
        "fields": {
          "file": {
            "type": "string",
            "copy_to": "copy"
          }
        }
      },
      "copy": {
        "type": "string"
      }
    }
  }
}

Going to fix this with documentation.

@dadoonet dadoonet added 2.4.2 and removed new labels Feb 11, 2015
@dadoonet dadoonet added this to the 2.4.2 milestone Feb 11, 2015
@dadoonet dadoonet changed the title copy_to using attachment field type and analyzer declaration [Doc] copy_to using attachment field type Feb 11, 2015
dadoonet added a commit that referenced this issue Feb 11, 2015
If you want to use [copy_to](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#copy-to)
feature, you need to define it on each sub-field you want to copy to another field:

```javascript
PUT /test/person/_mapping
{
  "person": {
    "properties": {
      "file": {
        "type": "attachment",
        "path": "full",
        "fields": {
          "file": {
            "type": "string",
            "copy_to": "copy"
          }
        }
      },
      "copy": {
        "type": "string"
      }
    }
  }
}
```

In this example, the extracted content will be copy as well to `copy` field.

Closes #97.
dadoonet added a commit that referenced this issue Feb 11, 2015
If you want to use [copy_to](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#copy-to)
feature, you need to define it on each sub-field you want to copy to another field:

```javascript
PUT /test/person/_mapping
{
  "person": {
    "properties": {
      "file": {
        "type": "attachment",
        "path": "full",
        "fields": {
          "file": {
            "type": "string",
            "copy_to": "copy"
          }
        }
      },
      "copy": {
        "type": "string"
      }
    }
  }
}
```

In this example, the extracted content will be copy as well to `copy` field.

Closes #97.
(cherry picked from commit f4f6b57)
@istvano
Copy link
Author

istvano commented Feb 11, 2015

Great thanks for this !

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

No branches or pull requests

2 participants