# Metadata: using one field to populate another

**URL:** <https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808>\
**Category:** Elasticsearch\
**Created:** [May 22, 2012, 4:12pm UTC](https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808 "2012-05-22T16:12:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jschelle\_2](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jschelle\_2](https://discuss.elastic.co/u/jschelle_2)\
**Post date:** [May 22, 2012, 4:12pm UTC](https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808/1 "2012-05-22T16:12:46Z")

</div>

I've been searching around trying to find the best way to do this, but  
haven't really found anything so far. Any help would be appreciated.  
Let's say I have simple documents that come in through a custom River:

doc:  
title: string  
content: string

And I want to add the following fields (numberOfNames, numberOfWords,  
numberOfPlaces) and populate them based on a custom parsing of the content  
field. Essentially I'm analyzing one field of the original document and  
using it to populate addition fields (not part of the original document) so  
that I can provided facetted search on these additional fields. Are there  
some existing approaches to do this? I would imagine this is pretty common  
but haven't been able to find much out there.

I was thinking of making a new Analyzer, something like MetadataAnalyzer  
where you could configure a sequence of Tokenizer and Filter objects that  
lead to the tokens to be indexed for a given field. For example you could  
do something like this:

index:  
analysis:  
analyzer:  
metadata\_analyzer:  
numberOfWords: WordsTokenizer, CountTokenFilter  
numberOfPlaces: WordsTokenizer, PlaceTokenFilter,  
CountTokenFilter  
numberOfNames: WordsTokenizer, NameTokenFilter, CountTokenFilter

Thoughts??

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 23, 2012, 3:06pm UTC](https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808/2 "2012-05-23T15:06:36Z")

</div>

If the only difference between each field is the analysis, you could  
use multi-fields on the original source field.

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Each field can have its own analyzer (custom or not). The primary use  
of multi-field is for when you want to define different analyzers on  
the same source field.

--  
Ivan

On Tue, May 22, 2012 at 9:12 AM, shadow000fire [jason.scheller@gmail.com](mailto:jason.scheller@gmail.com) wrote:

> I've been searching around trying to find the best way to do this, but  
> haven't really found anything so far. Any help would be appreciated. Let's  
> say I have simple documents that come in through a custom River:
> 
> doc:  
> title: string  
> content: string
> 
> And I want to add the following fields (numberOfNames, numberOfWords,  
> numberOfPlaces) and populate them based on a custom parsing of the content  
> field. Essentially I'm analyzing one field of the original document and  
> using it to populate addition fields (not part of the original document) so  
> that I can provided facetted search on these additional fields. Are there  
> some existing approaches to do this? I would imagine this is pretty common  
> but haven't been able to find much out there.
> 
> I was thinking of making a new Analyzer, something like MetadataAnalyzer  
> where you could configure a sequence of Tokenizer and Filter objects that  
> lead to the tokens to be indexed for a given field. For example you could  
> do something like this:
> 
> index:  
> analysis:  
> analyzer:  
> metadata\_analyzer:  
> numberOfWords: WordsTokenizer, CountTokenFilter  
> numberOfPlaces: WordsTokenizer, PlaceTokenFilter,  
> CountTokenFilter  
> numberOfNames: WordsTokenizer, NameTokenFilter, CountTokenFilter
> 
> Thoughts??

---

<div class="post-metadata">

**Author:** ![jschelle\_2](https://avatars.discourse-cdn.com/v4/letter/j/f475e1/32.png) [@jschelle\_2](https://discuss.elastic.co/u/jschelle_2)\
**Post date:** [May 23, 2012, 7:43pm UTC](https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808/3 "2012-05-23T19:43:18Z")

</div>

Oh perfect, thanks!

Thanks,  
Jay

On May 23, 2012, at 11:06 AM, Ivan Brusic [ivan@brusic.com](mailto:ivan@brusic.com) wrote:

> If the only difference between each field is the analysis, you could  
> use multi-fields on the original source field.
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html)
> 
> Each field can have its own analyzer (custom or not). The primary use  
> of multi-field is for when you want to define different analyzers on  
> the same source field.
> 
> --  
> Ivan
> 
> On Tue, May 22, 2012 at 9:12 AM, shadow000fire [jason.scheller@gmail.com](mailto:jason.scheller@gmail.com) wrote:
> 
> > I've been searching around trying to find the best way to do this, but  
> > haven't really found anything so far. Any help would be appreciated. Let's  
> > say I have simple documents that come in through a custom River:
> > 
> > doc:  
> > title: string  
> > content: string
> > 
> > And I want to add the following fields (numberOfNames, numberOfWords,  
> > numberOfPlaces) and populate them based on a custom parsing of the content  
> > field. Essentially I'm analyzing one field of the original document and  
> > using it to populate addition fields (not part of the original document) so  
> > that I can provided facetted search on these additional fields. Are there  
> > some existing approaches to do this? I would imagine this is pretty common  
> > but haven't been able to find much out there.
> > 
> > I was thinking of making a new Analyzer, something like MetadataAnalyzer  
> > where you could configure a sequence of Tokenizer and Filter objects that  
> > lead to the tokens to be indexed for a given field. For example you could  
> > do something like this:
> > 
> > index:  
> > analysis:  
> > analyzer:  
> > metadata\_analyzer:  
> > numberOfWords: WordsTokenizer, CountTokenFilter  
> > numberOfPlaces: WordsTokenizer, PlaceTokenFilter,  
> > CountTokenFilter  
> > numberOfNames: WordsTokenizer, NameTokenFilter, CountTokenFilter
> > 
> > Thoughts??

---

<div class="post-metadata">

**Author:** ![jconwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jconwell/32/4059_2.png) [@jconwell](https://discuss.elastic.co/u/jconwell)\
**Post date:** [July 16, 2015, 8:54pm UTC](https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808/4 "2015-07-16T20:54:03Z")

</div>

I'm trying to do something very similar.

Wouldn't using a multi-field for this scenario cause the same field to be tokenized 4 different times? Once for the normal text field tokenizaiton, and three times for each metric you are calculating.

Is there a way to perform all three analyses in one analyzer pipeline and then store the 3 resulting metrics to new fields?

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [July 16, 2015, 9:12pm UTC](https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808/5 "2015-07-16T21:12:01Z")

</div>

> [@jconwell](#):
>
> Is there a way to perform all three analyses in one analyzer pipeline and then store the 3 resulting metrics to new fields?

Not right now, no.

---

<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, 12:00am UTC](https://discuss.elastic.co/t/metadata-using-one-field-to-populate-another/7808/6 "2017-07-06T00:00:55Z")

</div>


