# Practical uses of \_source

**URL:** <https://discuss.elastic.co/t/practical-uses-of--source/6789>\
**Category:** Elasticsearch\
**Created:** [February 23, 2012, 1:30pm UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789 "2012-02-23T13:30:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![otisg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/otisg/32/492_2.png) [@otisg](https://discuss.elastic.co/u/otisg)\
**Post date:** [February 23, 2012, 1:30pm UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789/1 "2012-02-23T13:30:54Z")

</div>

Hello,

What are some of the most practical uses of \_source field?  
[http://www.elasticsearch.org/guide/reference/mapping/source-field.html](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)  
is a little thin on that...

I can think of the following:

1. can be used to return the original JSON for each hit (vs. ES having  
to construct that JSON on the fly from all saved fields)
2. can be used for updating individual fields on the server side
3. could be used for reindexing from ES (as opposed to from original  
data source) to a new version of ES

Are there other important uses of \_source field?

## Thanks, Otis

Search Analytics - [http://sematext.com/search-analytics/index.html](http://sematext.com/search-analytics/index.html)  
Scalable Performance Monitoring - [http://sematext.com/spm/index.html](http://sematext.com/spm/index.html)

---

<div class="post-metadata">

**Author:** ![egaumer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/egaumer/32/2365_2.png) [@egaumer](https://discuss.elastic.co/u/egaumer)\
**Post date:** [February 23, 2012, 1:44pm UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789/2 "2012-02-23T13:44:27Z")

</div>

We've built a few file sharing type applications where users can upload  
content such as PDFs, Office docs, zip files, etc. By maintaing the source,  
not only can users search for content, they can also download it. This  
makes it very easy to build a dropbox like application that runs behind a  
corporate firewall, where everything is highly discoverable.

---

<div class="post-metadata">

**Author:** ![Stephane\_Bastian](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@Stephane\_Bastian](https://discuss.elastic.co/u/Stephane_Bastian)\
**Post date:** [February 23, 2012, 2:05pm UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789/3 "2012-02-23T14:05:12Z")

</div>

Hello Otis,

We are using ElasticSearch as an Index (obviously 😉 and as some sort of  
NoSql Database. We store various entities such as Orders, Customer, etc. In  
this case, we only use the \_source field and based upon the settings of the  
config file, we decide which field of the \_source is indexed and which  
field is not.  
On top of that, we have built some sort of hibernate mapper that maps Java  
Object to json and back.  
I would say that the \_source field is a very important feature, that we use  
(and abuse?) on a daily basis

Hope this helps,

Stephane

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 23, 2012, 8:36pm UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789/4 "2012-02-23T20:36:19Z")

</div>

I'm also using \_source to highlight results.

BTW, it can be done also with fields.

> -----Message d'origine-----  
> De : [elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)  
> [[mailto:elasticsearch@googlegroups.com](mailto:elasticsearch@googlegroups.com)] De la part de Otis Gospodnetic  
> Envoyé : jeudi 23 février 2012 14:31  
> À : elasticsearch  
> Objet : Practical uses of \_source
> 
> Hello,
> 
> What are some of the most practical uses of \_source field?  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)  
> is a little thin on that...
> 
> I can think of the following:
> 
> 1. can be used to return the original JSON for each hit (vs. ES having  
> to construct that JSON on the fly from all saved fields)
> 2. can be used for updating individual fields on the server side
> 3. could be used for reindexing from ES (as opposed to from original  
> data source) to a new version of ES
> 
> Are there other important uses of \_source field?
> 
> ## Thanks, Otis
> 
> Search Analytics - [Cloud Monitoring Tools & Services | Sematext](http://sematext.com/search-analytics/index.html)  
> Scalable Performance Monitoring - [Sematext Monitoring | Infrastructure Monitoring Service](http://sematext.com/spm/index.html)

---

<div class="post-metadata">

**Author:** ![karmi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karmi/32/44951_2.png) [@karmi](https://discuss.elastic.co/u/karmi)\
**Post date:** [February 24, 2012, 7:46am UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789/5 "2012-02-24T07:46:14Z")

</div>

Hi,

> What are some of the most practical uses of \_source field?[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)  
> ...  
> I can think of the following:

the points you mention seem to approach the topic as if ES was "just a  
search engine" and you needeed to get the data from some other  
storage.

When you look at the `_source` as _the_ document itself, ES seems more  
like a database then "just a search engine". There'are already lots of  
people using ES as the persistence layer, as _the_ database. The  
[https://github.com/karmi/tire](https://github.com/karmi/tire) Ruby client, for example, has a  
ActiveModel-compatible interface, making ES a "drop replacement" for  
something like SQLite in a Ruby on Rails application (eg. \<https://

> <https://github.com/karmi/retire/tree/master/test/models>
>
> //github.com/karmi/retire/tree/master/test/models

persistent\_article\_with\_defaults.rb\>).

In my latest project, a social media monitoring tool, we use ES  
exclusively as the persistence layer. (We also use Redis for other  
data where we want fast access, such as user credentials, tokens,  
keywords, etc). We are _absolutely happy_ with the performance,  
features and ease of use of ES as the persistence layer, via the Ruby  
ActiveModel integration. (Previously, we have been using CouchDB.)

There are many more projects doing that, I suppose -- the Graylog2  
project, for instance, recently switched to ES from Mongo:  
[How to Reduce Software Development Costs in 2023? | AppMaster](http://www.lennartkoopmann.net/post/12512504316/whats-coming-graylog2-v096).

Best!,

Karel

---

<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:** [February 26, 2012, 7:27pm UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789/6 "2012-02-26T19:27:54Z")

</div>

Few more notes regarding the benefits of \_source:

1. Single stored (possibly compressed) field, compared to storing several fields. This means single field to load compared to several fields (faster). For example, using \_source to store 20 fields and fetching it is faster compared to storing those 20 fields on their own.
2. \_source can be used to get the actual document matching the search request, probably considerably faster compared to getting the actual data based on ids from another system.

The question is a bit misleading, since you compare \_source to specific stored fields (out of the json). I would say the question breaks down to two: Do we really want to store the actual data in ES, and what are the benefits? (highlighting, faster fetching). And, do we want to store the \_source on its own compared to storing specific fields.

On Friday, February 24, 2012 at 9:46 AM, Karel Minařík wrote:

> Hi,
> 
> > What are some of the most practical uses of \_source field?[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/source-field.html)  
> > ...  
> > I can think of the following:
> 
> the points you mention seem to approach the topic as if ES was "just a  
> search engine" and you needeed to get the data from some other  
> storage.
> 
> When you look at the `_source` as _the_ document itself, ES seems more  
> like a database then "just a search engine". There'are already lots of  
> people using ES as the persistence layer, as _the_ database. The  
> [https://github.com/karmi/tire](https://github.com/karmi/tire) Ruby client, for example, has a  
> ActiveModel-compatible interface, making ES a "drop replacement" for  
> something like SQLite in a Ruby on Rails application (eg. \<https://  
> [github.com/karmi/tire/blob/master/test/models/](http://github.com/karmi/tire/blob/master/test/models/) ([http://github.com/karmi/tire/blob/master/test/models/](http://github.com/karmi/tire/blob/master/test/models/))  
> persistent\_article\_with\_defaults.rb\>).
> 
> In my latest project, a social media monitoring tool, we use ES  
> exclusively as the persistence layer. (We also use Redis for other  
> data where we want fast access, such as user credentials, tokens,  
> keywords, etc). We are _absolutely happy_ with the performance,  
> features and ease of use of ES as the persistence layer, via the Ruby  
> ActiveModel integration. (Previously, we have been using CouchDB.)
> 
> There are many more projects doing that, I suppose -- the Graylog2  
> project, for instance, recently switched to ES from Mongo:  
> [How to Reduce Software Development Costs in 2023? | AppMaster](http://www.lennartkoopmann.net/post/12512504316/whats-coming-graylog2-v096).
> 
> Best!,
> 
> Karel

---

<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:38am UTC](https://discuss.elastic.co/t/practical-uses-of--source/6789/7 "2017-07-06T03:38:12Z")

</div>


