# Question about schemaless support

**URL:** <https://discuss.elastic.co/t/question-about-schemaless-support/5728>\
**Category:** Elasticsearch\
**Created:** [October 31, 2011, 2:59pm UTC](https://discuss.elastic.co/t/question-about-schemaless-support/5728 "2011-10-31T14:59:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomasz\_Kloc](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tomasz\_Kloc](https://discuss.elastic.co/u/Tomasz_Kloc)\
**Post date:** [October 31, 2011, 2:59pm UTC](https://discuss.elastic.co/t/question-about-schemaless-support/5728/1 "2011-10-31T14:59:11Z")

</div>

Hello,

I have an application based on mongodb, which uses main feature of nosql

- no schema at all. This is a common 'classified ads' application with  
collections of ads and categories. I didn't want to use EAV model, so  
i've chosen MongoDB. If category has some custom fields (ie. RAM for  
category Computers) I simple add this field to Ad record.  
Now I want to implement elasticsearch for search purposes and facet  
searches. I'm using Python & pyes library.  
Pyes documentation says that i have to:

1. create a connection (conn = pyes.ES() )
2. create an index ( conn.create\_index("test-index") )
3. put some document type (mapping)

Is this required? Document has dynamic fields and can look like  
{"id": ..., "title": ..., "price": ..., "ram": ... } for Computers  
or  
{"id": ..., "title": ..., "price": ..., "color": ...} for Cars

My questions are:

- do i have to create mapping for document?
- can i index these custom fields?
- can i search for objects with custom fields as filters?
- can i apply 'facets' to searches/queries described above?

or should i create mappings for each category with custom fields?

tk

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [October 31, 2011, 5:33pm UTC](https://discuss.elastic.co/t/question-about-schemaless-support/5728/2 "2011-10-31T17:33:43Z")

</div>

On Mon, Oct 31, 2011 at 4:59 PM, Tomasz Kloc [tomek.kloc.iit@gmail.com](mailto:tomek.kloc.iit@gmail.com)wrote:

> Hello,
> 
> I have an application based on mongodb, which uses main feature of nosql -  
> no schema at all. This is a common 'classified ads' application with  
> collections of ads and categories. I didn't want to use EAV model, so i've  
> chosen MongoDB. If category has some custom fields (ie. RAM for category  
> Computers) I simple add this field to Ad record.  
> Now I want to implement elasticsearch for search purposes and facet  
> searches. I'm using Python & pyes library.  
> Pyes documentation says that i have to:  
> 0) create a connection (conn = pyes.ES() )
> 
> 1. create an index ( conn.create\_index("test-index"\*\*) )
> 2. put some document type (mapping)
> 
> Is this required? Document has dynamic fields and can look like  
> {"id": ..., "title": ..., "price": ..., "ram": ... } for Computers  
> or  
> {"id": ..., "title": ..., "price": ..., "color": ...} for Cars
> 
> My questions are:
> 
> - do i have to create mapping for document?

You don't have to create mapping for those fields. The types for them will  
be automatically detected based on the first document indexed, and used. If  
you want to control the mappings, then you need to create mappings, but  
only for the fields you want to control.

> - can i index these custom fields?

Sure.

> - can i search for objects with custom fields as filters?

The fields are available for search in any form you want.

> - can i apply 'facets' to searches/queries described above?

Yes. Though note, sometimes you would want to make a field "not analyzed"  
for better facet results (so it won't be broken down into terms).

> or should i create mappings for each category with custom fields?
> 
> tk

---

<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, 3:50am UTC](https://discuss.elastic.co/t/question-about-schemaless-support/5728/3 "2017-07-06T03:50:21Z")

</div>


