# Multiple mappings with attachment

**URL:** <https://discuss.elastic.co/t/multiple-mappings-with-attachment/8726>\
**Category:** Elasticsearch\
**Created:** [August 13, 2012, 8:28am UTC](https://discuss.elastic.co/t/multiple-mappings-with-attachment/8726 "2012-08-13T08:28:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg\_Ievtushok](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/oleg_ievtushok/32/2745_2.png) [@Oleg\_Ievtushok](https://discuss.elastic.co/u/Oleg_Ievtushok)\
**Post date:** [August 13, 2012, 8:28am UTC](https://discuss.elastic.co/t/multiple-mappings-with-attachment/8726/1 "2012-08-13T08:28:23Z")

</div>

Hi,

I have the following problem - we need to index some documents by criteria:  
a) data in attachments(I use attachment plugin for this)  
b) some set of attributes(e.g. country, color)

The search is done by both of them(something like "a document containing  
elasticsearch and country=USA"). So my question is if I can create the  
following mapping:  
curl -X PUT "localhost:9200/search/data/\_mapping" -d '{  
"attachment" : {  
"properties" : {  
"file" : {  
"type" : "attachment",  
"fields" : {  
"title" : { "store" : "yes" },  
"file" : { "term\_vector":"with\_positions\_offsets", "store":"yes" }  
}  
}  
},  
"color" : { "type" : "string" },  
"category" : { "type" : "string" }  
}  
}'

and use one index instead of doing some legwork in application. What I  
could not find how to do is:

1. Update fields separately(especially if I can update the attachment field  
with "prepareUpdate")
2. Perform boolean query on few fields(e.g. attachment field + category)
3. If it could be done in some other way(but using the same index, because  
using few indexes and finding intersections on client-side doesn't seem to  
bee a good solution for me)

Thanks in advance

--

---

<div class="post-metadata">

**Author:** ![gondo\_2](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@gondo\_2](https://discuss.elastic.co/u/gondo_2)\
**Post date:** [April 23, 2013, 2:17pm UTC](https://discuss.elastic.co/t/multiple-mappings-with-attachment/8726/2 "2013-04-23T14:17:54Z")

</div>

i believe that this is possible but you should put color and category  
inside the properties:

'{  
"attachment" : {  
"properties" : {  
"file" : {  
"type" : "attachment",  
"fields" : {  
"title" : { "store" : "yes" },  
"file" : { "term\_vector":"with\_positions\_offsets", "store":"yes" }  
}  
},  
"color" : { "type" : "string" },  
"category" : { "type" : "string" }  
}  
}  
}

On Monday, 13 August 2012 18:28:23 UTC+10, Oleg Ievtushok wrote:

> Hi,
> 
> I have the following problem - we need to index some documents  
> by criteria:  
> a) data in attachments(I use attachment plugin for this)  
> b) some set of attributes(e.g. country, color)
> 
> The search is done by both of them(something like "a document containing  
> elasticsearch and country=USA"). So my question is if I can create the  
> following mapping:  
> curl -X PUT "localhost:9200/search/data/\_mapping" -d '{  
> "attachment" : {  
> "properties" : {  
> "file" : {  
> "type" : "attachment",  
> "fields" : {  
> "title" : { "store" : "yes" },  
> "file" : { "term\_vector":"with\_positions\_offsets", "store":"yes"  
> }  
> }  
> }  
> },  
> "color" : { "type" : "string" },  
> "category" : { "type" : "string" }  
> }  
> }'
> 
> and use one index instead of doing some legwork in application. What I  
> could not find how to do is:
> 
> 1. Update fields separately(especially if I can update the attachment  
> field with "prepareUpdate")
> 2. Perform boolean query on few fields(e.g. attachment field + category)
> 3. If it could be done in some other way(but using the same index, because  
> using few indexes and finding intersections on client-side doesn't seem to  
> bee a good solution for me)
> 
> Thanks in advance

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:39am UTC](https://discuss.elastic.co/t/multiple-mappings-with-attachment/8726/3 "2017-07-06T02:39:57Z")

</div>


