# Which index and store atrributes of string field in explict mapping?

**URL:** https://discuss.elastic.co/t/which-index-and-store-atrributes-of-string-field-in-explict-mapping/12660
**Category:** Elasticsearch
**Created:** [July 4, 2013, 10:15am UTC](https://discuss.elastic.co/t/which-index-and-store-atrributes-of-string-field-in-explict-mapping/12660 "2013-07-04T10:15:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Mithrawnuroudo](https://avatars.discourse-cdn.com/v4/letter/m/898d66/32.png) [@Mithrawnuroudo](https://discuss.elastic.co/u/Mithrawnuroudo)
#### Post date: [July 4, 2013, 10:15am UTC](https://discuss.elastic.co/t/which-index-and-store-atrributes-of-string-field-in-explict-mapping/12660/1 "2013-07-04T10:15:11Z")

</div>

Hello,  
I'm writting this post because i am new ES user and i am not sure if i understand correctly index and store attributes of string fields in explict mapping.

I want to have an ES index which contans list of internet sites.  
The document type "site" has 3 fields: url, content, inner\_note

I will be searching documents which contains given phrases in "content" field.  
I will be retrieving single document which has particular url in "url" field.  
The field "inner\_note" is only for my internal use and i will not use this field to searching/retrieving documents.

I prepared following mapping:

```
"site" : {
    "properties" : {
        "url" : {"type" : "string","store" : "no", "index" : "not_analyzed"},
        "content" : {"type" : "string", "store" : "yes", "index" : "analyzed"},
        "inner_note" : {"type" : "string","store" : "no", "index" : "no"}
    }

```

and i have following questions:

1. Have i choosed optimal "store" and "index" attributes for my scenario?
2. Is retrieving document by url field as fast as i would retrieve by ID? Comparing to traditional SQL version: if i want to retrieve single row in SQL table by WHERE url = ? i would create SQL index on url column.

I would be grateful for any help!

Best regards

---

<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: [July 10, 2013, 7:59am UTC](https://discuss.elastic.co/t/which-index-and-store-atrributes-of-string-field-in-explict-mapping/12660/2 "2013-07-10T07:59:27Z")

</div>

Hello,

On Thu, Jul 4, 2013 at 1:15 PM, Mithrawnuroudo [mojcalyspam@gmail.com](mailto:mojcalyspam@gmail.com)wrote:

> Hello,  
> I'm writting this post because i am new ES user and i am not sure if i  
> understand correctly index and store attributes of string fields in explict  
> mapping.

the "index" attribute tells ES how to index your field:

- "analyzed" will break it in terms, so by default you'll be able to  
search, for example, for a single word in that field
- "not\_analyzed" will just index your field as a single term, so only exact  
matches will return results
- "no" won't index your field at all, making your field unsearcheable

"store" tells ES to store the contents of your field or not.

However, there's are two more things to consider here:

- the \_all field[http://www.elasticsearch.org/guide/reference/mapping/all-field/](http://www.elasticsearch.org/guide/reference/mapping/all-field/),  
which by default indexes all your fields. So if you set index: no to a  
field, you might still be able to search in it using \_all
- the \_source field[http://www.elasticsearch.org/guide/reference/mapping/source-field/](http://www.elasticsearch.org/guide/reference/mapping/source-field/),  
which by default stores all your fields. So even if you don't store any  
field, you can retrieve the contents, because ES will take them from  
\_source. Typically, you'd store individual fields if you disable \_source

> I want to have an ES index which contans list of internet sites.  
> The document type "site" has 3 fields: url, content, inner\_note
> 
> I will be searching documents which contains given phrases in "content"  
> field.  
> I will be retrieving single document which has particular url in "url"  
> field.  
> The field "inner\_note" is only for my internal use and i will not use this  
> field to searching/retrieving documents.
> 
> I prepared following mapping:
> 
> ```
> "site" : {
> "properties" : {
> "url" : {"type" : "string","store" : "no", "index" :
> 
> ```
> 
> "not\_analyzed"},  
> "content" : {"type" : "string", "store" : "yes", "index" :  
> "analyzed"},  
> "inner\_note" : {"type" : "string","store" : "no", "index" :  
> "no"}  
> }
> 
> and i have following questions:
> 
> 1. Have i choosed optimal "store" and "index" attributes for my scenario?

It should work. I'm not sure about the "optimal" part. I wouldn't store the  
"content" field, because it can be retrieved anyway, by using \_source.

> 1. Is retrieving document by url field as fast as i would retrieve by ID?

Getting by ID is faster, because it doesn't imply a search (even though  
your url searches should be fast enough, because you have not\_analyzed so  
you have a low number of terms). Plus, getting is realtime, as described  
here:

> **[Elastic — The Search AI Company](https://www.elastic.co)**
>
> Power insights and outcomes with The Elastic Search AI Platform. See into your data and find answers that matter with enterprise solutions designed to help you accelerate time to insight. Try Elastic ...

> Comparing to traditional SQL version: if i want to retrieve single row in  
> SQL table by WHERE url = ? i would create SQL index on url column.

In the case of ES, the fields are indexed by default. You have to say  
index: no if you want it otherwise.

> I would be grateful for any help!

I hope this helps 🙂

## 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: ![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:27am UTC](https://discuss.elastic.co/t/which-index-and-store-atrributes-of-string-field-in-explict-mapping/12660/3 "2017-07-06T02:27:20Z")

</div>


