# Multi valued field with variable index time "analyzed" setting - how to do this using elastic search?

**URL:** <https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361>\
**Category:** Elasticsearch\
**Created:** [January 12, 2012, 8:23am UTC](https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361 "2012-01-12T08:23:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kai\_lilleby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kai_lilleby/32/3019_2.png) [@kai\_lilleby](https://discuss.elastic.co/u/kai_lilleby)\
**Post date:** [January 12, 2012, 8:23am UTC](https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361/1 "2012-01-12T08:23:31Z")

</div>

Trying to migrate from using Lucene directly to using Elastic Search,  
ive stumbled upon the following challenge:

My Lucene code:  
document = new Document() ...  
document.add(new Field("fieldname", valueMustNOTBeAnalyzed,  
Field.Store.YES, Field.Index.NOT\_ANALYZED));  
document.add(new Field("fieldname, valueMustBeAnalyzed,  
Field.Store.YES, Field.Index.ANALYZED));  
... add document to index...

How do i handle this using Elastic Search?  
Any ideas?

---

<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:** [January 12, 2012, 10:52am UTC](https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361/2 "2012-01-12T10:52:40Z")

</div>

In the mapping of a specific field, you can specify that its not\_analyzed  
under its "index" option. See more there:  
[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html).

On Thu, Jan 12, 2012 at 10:23 AM, Kai Lilleby [kai@systemfabrikken.no](mailto:kai@systemfabrikken.no)wrote:

> Trying to migrate from using Lucene directly to using Elastic Search,  
> ive stumbled upon the following challenge:
> 
> My Lucene code:  
> document = new Document() ...  
> document.add(new Field("fieldname", valueMustNOTBeAnalyzed,  
> Field.Store.YES, Field.Index.NOT\_ANALYZED));  
> document.add(new Field("fieldname, valueMustBeAnalyzed,  
> Field.Store.YES, Field.Index.ANALYZED));  
> ... add document to index...
> 
> How do i handle this using Elastic Search?  
> Any ideas?

---

<div class="post-metadata">

**Author:** ![kai\_lilleby](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kai_lilleby/32/3019_2.png) [@kai\_lilleby](https://discuss.elastic.co/u/kai_lilleby)\
**Post date:** [January 12, 2012, 4:42pm UTC](https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361/3 "2012-01-12T16:42:36Z")

</div>

Tanks for quick reply!  
To be more presise - im looking for the ability to specify wether to  
analyze the field at index request time - not at setup/mapping  
definition time - as one can when adding Field to a lucene Document.

My second question is: how does ES support multi valued fields - ie in  
lucene: adding several Field instances to one and the same Document  
using the same field name but different settings , eg. adding product  
number as not-analyzed but product description analyzed - using the  
same field name

Kai:)

On Jan 12, 11:52 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> In the mapping of a specific field, you can specify that its not\_analyzed  
> under its "index" option. See more there:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html).
> 
> On Thu, Jan 12, 2012 at 10:23 AM, Kai Lilleby [k...@systemfabrikken.no](mailto:k...@systemfabrikken.no)wrote:
> 
> > Trying to migrate from using Lucene directly to using Elastic Search,  
> > ive stumbled upon the following challenge:
> 
> > My Lucene code:  
> > document = new Document() ...  
> > document.add(new Field("fieldname", valueMustNOTBeAnalyzed,  
> > Field.Store.YES, Field.Index.NOT\_ANALYZED));  
> > document.add(new Field("fieldname, valueMustBeAnalyzed,  
> > Field.Store.YES, Field.Index.ANALYZED));  
> > ... add document to index...
> 
> > How do i handle this using Elastic Search?  
> > Any ideas?

---

<div class="post-metadata">

**Author:** ![vinhphu1711](https://avatars.discourse-cdn.com/v4/letter/v/a88e4f/32.png) [@vinhphu1711](https://discuss.elastic.co/u/vinhphu1711)\
**Post date:** [February 6, 2012, 1:45am UTC](https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361/4 "2012-02-06T01:45:42Z")

</div>

Hi Kia,  
Do you mean this one [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html) ?  
On Jan 13, 2012, at 12:42 AM, Kai Lilleby wrote:

> Tanks for quick reply!  
> To be more presise - im looking for the ability to specify wether to  
> analyze the field at index request time - not at setup/mapping  
> definition time - as one can when adding Field to a lucene Document.
> 
> My second question is: how does ES support multi valued fields - ie in  
> lucene: adding several Field instances to one and the same Document  
> using the same field name but different settings , eg. adding product  
> number as not-analyzed but product description analyzed - using the  
> same field name
> 
> Kai:)
> 
> On Jan 12, 11:52 am, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > In the mapping of a specific field, you can specify that its not\_analyzed  
> > under its "index" option. See more there:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html).
> > 
> > On Thu, Jan 12, 2012 at 10:23 AM, Kai Lilleby [k...@systemfabrikken.no](mailto:k...@systemfabrikken.no)wrote:
> > 
> > > Trying to migrate from using Lucene directly to using Elastic Search,  
> > > ive stumbled upon the following challenge:
> > 
> > > My Lucene code:  
> > > document = new Document() ...  
> > > document.add(new Field("fieldname", valueMustNOTBeAnalyzed,  
> > > Field.Store.YES, Field.Index.NOT\_ANALYZED));  
> > > document.add(new Field("fieldname, valueMustBeAnalyzed,  
> > > Field.Store.YES, Field.Index.ANALYZED));  
> > > ... add document to index...
> > 
> > > How do i handle this using Elastic Search?  
> > > Any ideas?

---

<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 7, 2012, 10:03am UTC](https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361/5 "2012-02-07T10:03:16Z")

</div>

It makes little sense to add under the same field name in Lucene fields with different analysis settings. But, as was noted, the multi field type can be used to have the same json data be indexed differently under different field names.

On Monday, February 6, 2012 at 3:45 AM, Phu Le wrote:

> Hi Kia,  
> Do you mean this one [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html) ?  
> On Jan 13, 2012, at 12:42 AM, Kai Lilleby wrote:
> 
> > Tanks for quick reply!  
> > To be more presise - im looking for the ability to specify wether to  
> > analyze the field at index request time - not at setup/mapping  
> > definition time - as one can when adding Field to a lucene Document.
> > 
> > My second question is: how does ES support multi valued fields - ie in  
> > lucene: adding several Field instances to one and the same Document  
> > using the same field name but different settings , eg. adding product  
> > number as not-analyzed but product description analyzed - using the  
> > same field name
> > 
> > Kai:)
> > 
> > On Jan 12, 11:52 am, Shay Banon \<[kim...@gmail.com](mailto:kim...@gmail.com) ([http://gmail.com](http://gmail.com))\> wrote:
> > 
> > > In the mapping of a specific field, you can specify that its not\_analyzed  
> > > under its "index" option. See more there:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html).
> > > 
> > > On Thu, Jan 12, 2012 at 10:23 AM, Kai Lilleby [k...@systemfabrikken.no](mailto:k...@systemfabrikken.no)wrote:
> > > 
> > > > Trying to migrate from using Lucene directly to using Elastic Search,  
> > > > ive stumbled upon the following challenge:
> > > 
> > > > My Lucene code:  
> > > > document = new Document() ...  
> > > > document.add(new Field("fieldname", valueMustNOTBeAnalyzed,  
> > > > Field.Store.YES, Field.Index.NOT\_ANALYZED));  
> > > > document.add(new Field("fieldname, valueMustBeAnalyzed,  
> > > > Field.Store.YES, Field.Index.ANALYZED));  
> > > > ... add document to index...
> > > 
> > > > How do i handle this using Elastic Search?  
> > > > Any ideas?

---

<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:40am UTC](https://discuss.elastic.co/t/multi-valued-field-with-variable-index-time-analyzed-setting-how-to-do-this-using-elastic-search/6361/6 "2017-07-06T03:40:23Z")

</div>


