# How can I change indexed expression for a field?

**URL:** <https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202>\
**Category:** Elasticsearch\
**Created:** [December 29, 2012, 10:57pm UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202 "2012-12-29T22:57:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Burak\_Emre\_Kabakci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/burak_emre_kabakci/32/2212_2.png) [@Burak\_Emre\_Kabakci](https://discuss.elastic.co/u/Burak_Emre_Kabakci)\
**Post date:** [December 29, 2012, 10:57pm UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/1 "2012-12-29T22:57:33Z")

</div>

Can I manually change the indexed term for a field? For example, the  
expression is "this is a test". The \_source field will keep the actual  
expression "this is a test" but it will be indexed as "this is a test or  
example" so I elasticsearch will return this document when I query  
"example".

--

---

<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:** [December 30, 2012, 3:00am UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/2 "2012-12-30T03:00:17Z")

</div>

I don't know if you can do that using scripts.  
If not, you can build your own plugin mapper.

I wrote a sample project here: [https://github.com/dadoonet/elasticsearch-mapper-demo](https://github.com/dadoonet/elasticsearch-mapper-demo)

It takes a field from source and UPPERCASE it in another field during index phase.  
Instead of uppercase, you can do what you want...

## HTH

David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 29 déc. 2012 à 23:57, Burak Emre Kabakcı [emrekabakci@gmail.com](mailto:emrekabakci@gmail.com) a écrit :

## Can I manually change the indexed term for a field? For example, the expression is "this is a test". The \_source field will keep the actual expression "this is a test" but it will be indexed as "this is a test or example" so I elasticsearch will return this document when I query "example".

--

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 30, 2012, 1:22pm UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/3 "2012-12-30T13:22:55Z")

</div>

Hey there,

the synonym filter provides a similar functionality you might be searching  
for... if you provide a more exact use-case, perhaps someone has a more  
exact idea

> **[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.

--Alex

On Sat, Dec 29, 2012 at 11:57 PM, Burak Emre Kabakcı  
[emrekabakci@gmail.com](mailto:emrekabakci@gmail.com)wrote:

> Can I manually change the indexed term for a field? For example, the  
> expression is "this is a test". The \_source field will keep the actual  
> expression "this is a test" but it will be indexed as "this is a test or  
> example" so I elasticsearch will return this document when I query  
> "example".
> 
> --

--

---

<div class="post-metadata">

**Author:** ![Burak\_Emre\_Kabakci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/burak_emre_kabakci/32/2212_2.png) [@Burak\_Emre\_Kabakci](https://discuss.elastic.co/u/Burak_Emre_Kabakci)\
**Post date:** [December 30, 2012, 3:04pm UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/4 "2012-12-30T15:04:52Z")

</div>

Synonym may not work for me. I have an index called artist and some of  
these artists have nickname or acronym. (Actually I use Musicbrainz and  
there is more explanation here:  
[Style / Aliases - MusicBrainz](http://musicbrainz.org/doc/Style/Artist/Aliases)) I don't want to store  
these nicknames or acronyms etc. but it I want to index "name" field with  
all of them.

On Sunday, December 30, 2012 3:22:55 PM UTC+2, Alexander Reelsen wrote:

> Hey there,
> 
> the synonym filter provides a similar functionality you might be searching  
> for... if you provide a more exact use-case, perhaps someone has a more  
> exact idea
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html)
> 
> --Alex
> 
> On Sat, Dec 29, 2012 at 11:57 PM, Burak Emre Kabakcı \<[emrek...@gmail.com](mailto:emrek...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Can I manually change the indexed term for a field? For example, the  
> > expression is "this is a test". The \_source field will keep the actual  
> > expression "this is a test" but it will be indexed as "this is a test or  
> > example" so I elasticsearch will return this document when I query  
> > "example".
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Burak\_Emre\_Kabakci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/burak_emre_kabakci/32/2212_2.png) [@Burak\_Emre\_Kabakci](https://discuss.elastic.co/u/Burak_Emre_Kabakci)\
**Post date:** [December 30, 2012, 3:17pm UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/5 "2012-12-30T15:17:24Z")

</div>

It seems great but I must be able to get extra expressions for the field. I  
can pass a json string as a value for "name" field and decode it in mapper  
plugin but then I also have to edit the stored field value in \_source  
field. An another option I can think of is to add extra fields  
called nickname and acronym that are neither indexed nor stored in \_source  
field. If I can get these values in mapper plugin I can manually append the  
value of nickname and acronym to "name" field and analyze it with standard  
analyzer. However I'm not sure I get the value of a field that are neither  
indexed nor stored in \_source field in mapper plugin.

On Sunday, December 30, 2012 5:00:17 AM UTC+2, David Pilato wrote:

> I don't know if you can do that using scripts.  
> If not, you can build your own plugin mapper.
> 
> I wrote a sample project here:  
> [GitHub - dadoonet/elasticsearch-mapper-demo: Mapper Demo Plugin for Elasticsearch](https://github.com/dadoonet/elasticsearch-mapper-demo)
> 
> It takes a field from source and UPPERCASE it in another field during  
> index phase.  
> Instead of uppercase, you can do what you want...
> 
> ## HTH
> 
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 29 déc. 2012 à 23:57, Burak Emre Kabakcı \<[emrek...@gmail.com](mailto:emrek...@gmail.com)\<javascript:\>\>  
> a écrit :
> 
> Can I manually change the indexed term for a field? For example, the  
> expression is "this is a test". The \_source field will keep the actual  
> expression "this is a test" but it will be indexed as "this is a test or  
> example" so I elasticsearch will return this document when I query  
> "example".
> 
> --

--

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 31, 2012, 5:02pm UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/6 "2012-12-31T17:02:02Z")

</div>

Hey,

ok synonyms doesnt make any sense for your usecase. What about the \_all  
field, which may contain the artist name as well as the aliases (see  
include\_in\_all) and can be used for searching as well?

--Alex

On Sun, Dec 30, 2012 at 4:04 PM, Burak Emre Kabakcı  
[emrekabakci@gmail.com](mailto:emrekabakci@gmail.com)wrote:

> Synonym may not work for me. I have an index called artist and some of  
> these artists have nickname or acronym. (Actually I use Musicbrainz and  
> there is more explanation here:  
> [Style / Aliases - MusicBrainz](http://musicbrainz.org/doc/Style/Artist/Aliases)) I don't want to store  
> these nicknames or acronyms etc. but it I want to index "name" field with  
> all of them.
> 
> On Sunday, December 30, 2012 3:22:55 PM UTC+2, Alexander Reelsen wrote:
> 
> > Hey there,
> > 
> > the synonym filter provides a similar functionality you might be  
> > searching for... if you provide a more exact use-case, perhaps someone has  
> > a more exact idea  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**guide/reference/index-modules/)\*\*  
> > analysis/synonym-tokenfilter.\*\*html[http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html](http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html)
> > 
> > --Alex
> > 
> > On Sat, Dec 29, 2012 at 11:57 PM, Burak Emre Kabakcı [emrek...@gmail.com](mailto:emrek...@gmail.com)wrote:
> > 
> > > Can I manually change the indexed term for a field? For example, the  
> > > expression is "this is a test". The \_source field will keep the actual  
> > > expression "this is a test" but it will be indexed as "this is a test or  
> > > example" so I elasticsearch will return this document when I query  
> > > "example".
> > > 
> > > --
> > 
> > --

--

---

<div class="post-metadata">

**Author:** ![Burak\_Emre\_Kabakci](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/burak_emre_kabakci/32/2212_2.png) [@Burak\_Emre\_Kabakci](https://discuss.elastic.co/u/Burak_Emre_Kabakci)\
**Post date:** [December 31, 2012, 5:24pm UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/7 "2012-12-31T17:24:54Z")

</div>

Actually I disabled \_all field to decrease memory usage. I thought  
that "include\_in\_all": true may not work with "index": "no" but it seems  
ok. Now I set name field and all related fields "include\_in\_all":  
true, "index": "no" and I'm able to search correctly with \_all field.  
Thanks!

On Monday, December 31, 2012 7:02:02 PM UTC+2, Alexander Reelsen wrote:

> Hey,
> 
> ok synonyms doesnt make any sense for your usecase. What about the \_all  
> field, which may contain the artist name as well as the aliases (see  
> include\_in\_all) and can be used for searching as well?
> 
> --Alex
> 
> On Sun, Dec 30, 2012 at 4:04 PM, Burak Emre Kabakcı \<[emrek...@gmail.com](mailto:emrek...@gmail.com)\<javascript:\>
> 
> > wrote:
> 
> > Synonym may not work for me. I have an index called artist and some of  
> > these artists have nickname or acronym. (Actually I use Musicbrainz and  
> > there is more explanation here:  
> > [Style / Aliases - MusicBrainz](http://musicbrainz.org/doc/Style/Artist/Aliases)) I don't want to store  
> > these nicknames or acronyms etc. but it I want to index "name" field with  
> > all of them.
> > 
> > On Sunday, December 30, 2012 3:22:55 PM UTC+2, Alexander Reelsen wrote:
> > 
> > > Hey there,
> > > 
> > > the synonym filter provides a similar functionality you might be  
> > > searching for... if you provide a more exact use-case, perhaps someone has  
> > > a more exact idea  
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/**guide/reference/index-modules/)\*\*  
> > > analysis/synonym-tokenfilter.\*\*html[http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html](http://www.elasticsearch.org/guide/reference/index-modules/analysis/synonym-tokenfilter.html)
> > > 
> > > --Alex
> > > 
> > > On Sat, Dec 29, 2012 at 11:57 PM, Burak Emre Kabakcı \<[emrek...@gmail.com](mailto:emrek...@gmail.com)
> > > 
> > > > wrote:
> > > 
> > > > Can I manually change the indexed term for a field? For example, the  
> > > > expression is "this is a test". The \_source field will keep the actual  
> > > > expression "this is a test" but it will be indexed as "this is a test or  
> > > > example" so I elasticsearch will return this document when I query  
> > > > "example".
> > > > 
> > > > --
> > > 
> > > --

--

---

<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:58am UTC](https://discuss.elastic.co/t/how-can-i-change-indexed-expression-for-a-field/10202/8 "2017-07-06T02:58:06Z")

</div>


