# Some questions about schema/mapping/indexes/filters

**URL:** <https://discuss.elastic.co/t/some-questions-about-schema-mapping-indexes-filters/13425>\
**Category:** Elasticsearch\
**Created:** [September 1, 2013, 11:06pm UTC](https://discuss.elastic.co/t/some-questions-about-schema-mapping-indexes-filters/13425 "2013-09-01T23:06:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [September 1, 2013, 11:06pm UTC](https://discuss.elastic.co/t/some-questions-about-schema-mapping-indexes-filters/13425/1 "2013-09-01T23:06:53Z")

</div>

I'm new to elastic search and i've read some of the docs and still have  
some questions:

1. I have a 'user' document. This user can belong to several 'groups'  
and have several settings for each group. How can i have a mapping so i can  
search on users that have a group\_id and administrator in that group  
storing all data in the user document?
2. Fields that aren't specified in the mapping are not indexed? Because  
i don't want to index/search on every field.
3. Are documents/\_source compressed together in blocks or separately?
4. If i store the \_source i don't need to store fields?
5. If i update a document and change a non-indexed/non-mapped field will  
the document be reindexed?
6. If i only want to text-search on 3 fields(title,arrays[],description)  
should i put only these in the \_all field or something else?
7. Can i search 'more\_like\_this' WHERE a=1 AND b=24 AND c=True ?
8. Should i use ECC RAM ?

Thanks

--  
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:** ![radu\_gheorghe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe/32/556_2.png) [@radu\_gheorghe](https://discuss.elastic.co/u/radu_gheorghe)\
**Post date:** [September 3, 2013, 11:05am UTC](https://discuss.elastic.co/t/some-questions-about-schema-mapping-indexes-filters/13425/2 "2013-09-03T11:05:52Z")

</div>

Hello,

I'll answer inline. Excuse my Gmail messing with your numbering ☹

On Mon, Sep 2, 2013 at 2:06 AM, ddorian43 [dorian.hoxha@gmail.com](mailto:dorian.hoxha@gmail.com) wrote:

> I'm new to Elasticsearch and i've read some of the docs and still have  
> some questions:
> 
> 1. I have a 'user' document. This user can belong to several 'groups'  
> and have several settings for each group. How can i have a mapping so i can  
> search on users that have a group\_id and administrator in that group  
> storing all data in the user document?

You can have a nested  
type[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)under  
each user, to get something like:

{  
"name": "test-user",  
"groups": [  
{  
"group\_id": 1,  
"is\_admin": true  
},  
{  
"group\_id": 2,  
"is\_admin": false  
}  
]  
}

And then to search, you can wrap a bool  
query[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)in  
a nested  
query [http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and  
specify the group\_id and the is\_admin value you need. And it will only  
match users who have a group object with both properties.

> 1. Fields that aren't specified in the mapping are not indexed?  
> Because i don't want to index/search on every field.

If a field is not in the mapping, when you add a new document that has it,  
ES will try and guess what that field is and append the mapping for you.  
Unless you disable dynamic mappings, in which case indexing that document  
will fail.

If you need to disable indexing a field, you can have "index": "no" for  
that field. Its content will still be stored in the \_source field.

> 1. 
> 2. Are documents/\_source compressed together in blocks or separately?

In 0.90 or later, they're compressed in blocks.

> 1. If i store the \_source i don't need to store fields?

No, the fields will be retrieved from source. You can still store  
individual fields (or store fields and not \_source), but the default is  
recommended.

> 1. If i update a document and change a non-indexed/non-mapped field  
> will the document be reindexed?

When you update a document, it's reindexed. A field that's not mapped can't  
be changed, because it means it's not there. If a field is stored, but not  
indexed, it can be updated, but it will still not be indexed. I hope this  
answers your question, because I'm not sure I'm getting it.

> 1. If i only want to text-search on 3  
> fields(title,arrays,description) should i put only these in the \_all  
> field or something else?

That's an option, yes. Or you can search in all three fields (for example,  
by using a multi\_match or a bool query).

> 1. Can i search 'more\_like\_this' WHERE a=1 AND b=24 AND c=True ?

I don't think you can. For integers and booleans, you can simply query for  
those values using something like a term query.

> 1. Should i use ECC RAM ?

If it's something your motherboard supports, I guess some extra reliability  
never hurts 🙂

## Best regards, Radu

[http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene

--  
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:** ![ddorian43](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ddorian43/32/36093_2.png) [@ddorian43](https://discuss.elastic.co/u/ddorian43)\
**Post date:** [September 3, 2013, 10:31pm UTC](https://discuss.elastic.co/t/some-questions-about-schema-mapping-indexes-filters/13425/3 "2013-09-03T22:31:35Z")

</div>

Thanks for the answers. So i need to map every field. What about:

1. How to map a 'map' field where i don't know the keys and don't want  
to index it ? Or is there a index\_field\_default:False?
2. Documents of different types inside 1 index with the same  
\_routing.value will reside in the same shard?
3. If i want autocomplete on arrays i would need n-grams. If i n-gram  
arrays does it go as whole words in the \_all field (i want to)? Should i  
use multi\_type?
4. Is it better(performance) to use 1index with 7 types or 7 indexes  
with 1 type each (will never search all types at the same time)?

On Tue, Sep 3, 2013 at 1:05 PM, Radu Gheorghe [radu.gheorghe@sematext.com](mailto:radu.gheorghe@sematext.com)wrote:

> Hello,
> 
> I'll answer inline. Excuse my Gmail messing with your numbering ☹
> 
> On Mon, Sep 2, 2013 at 2:06 AM, ddorian43 [dorian.hoxha@gmail.com](mailto:dorian.hoxha@gmail.com) wrote:
> 
> > I'm new to Elasticsearch and i've read some of the docs and still have  
> > some questions:
> > 
> > 1. I have a 'user' document. This user can belong to several 'groups'  
> > and have several settings for each group. How can i have a mapping so i can  
> > search on users that have a group\_id and administrator in that group  
> > storing all data in the user document?
> 
> You can have a nested type[http://www.elasticsearch.org/guide/reference/mapping/nested-type/](http://www.elasticsearch.org/guide/reference/mapping/nested-type/)under each user, to get something like:
> 
> {  
> "name": "test-user",  
> "groups": [  
> {  
> "group\_id": 1,  
> "is\_admin": true  
> },  
> {  
> "group\_id": 2,  
> "is\_admin": false  
> }  
> ]  
> }
> 
> And then to search, you can wrap a bool query[http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html](http://www.elasticsearch.org/guide/reference/query-dsl/bool-query.html)in a nested  
> query[http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/](http://www.elasticsearch.org/guide/reference/query-dsl/nested-query/)and specify the group\_id and the is\_admin value you need. And it will only  
> match users who have a group object with both properties.
> 
> > 1. Fields that aren't specified in the mapping are not indexed?  
> > Because i don't want to index/search on every field.
> 
> If a field is not in the mapping, when you add a new document that has it,  
> ES will try and guess what that field is and append the mapping for you.  
> Unless you disable dynamic mappings, in which case indexing that document  
> will fail.
> 
> If you need to disable indexing a field, you can have "index": "no" for  
> that field. Its content will still be stored in the \_source field.
> 
> > 1. 
> > 2. Are documents/\_source compressed together in blocks or separately?
> 
> In 0.90 or later, they're compressed in blocks.
> 
> > 1. If i store the \_source i don't need to store fields?
> 
> No, the fields will be retrieved from source. You can still store  
> individual fields (or store fields and not \_source), but the default is  
> recommended.
> 
> > 1. If i update a document and change a non-indexed/non-mapped field  
> > will the document be reindexed?
> 
> When you update a document, it's reindexed. A field that's not mapped  
> can't be changed, because it means it's not there. If a field is stored,  
> but not indexed, it can be updated, but it will still not be indexed. I  
> hope this answers your question, because I'm not sure I'm getting it.
> 
> > 1. If i only want to text-search on 3  
> > fields(title,arrays,description) should i put only these in the \_all  
> > field or something else?
> 
> That's an option, yes. Or you can search in all three fields (for example,  
> by using a multi\_match or a bool query).
> 
> > 1. Can i search 'more\_like\_this' WHERE a=1 AND b=24 AND c=True ?
> 
> I don't think you can. For integers and booleans, you can simply query for  
> those values using something like a term query.
> 
> > 1. Should i use ECC RAM ?
> 
> If it's something your motherboard supports, I guess some extra  
> reliability never hurts 🙂
> 
> ## Best regards, Radu
> 
> [http://sematext.com/](http://sematext.com/) -- Elasticsearch -- Solr -- Lucene
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit  
> [https://groups.google.com/d/topic/elasticsearch/9o\_RuNfSK4Q/unsubscribe](https://groups.google.com/d/topic/elasticsearch/9o_RuNfSK4Q/unsubscribe).  
> To unsubscribe from this group and all its topics, 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).

--  
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:18am UTC](https://discuss.elastic.co/t/some-questions-about-schema-mapping-indexes-filters/13425/4 "2017-07-06T02:18:20Z")

</div>


