# Indexing computed/scripted fields

**URL:** <https://discuss.elastic.co/t/indexing-computed-scripted-fields/13956>\
**Category:** Elasticsearch\
**Created:** [October 15, 2013, 5:36pm UTC](https://discuss.elastic.co/t/indexing-computed-scripted-fields/13956 "2013-10-15T17:36:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [October 15, 2013, 5:36pm UTC](https://discuss.elastic.co/t/indexing-computed-scripted-fields/13956/1 "2013-10-15T17:36:05Z")

</div>

Hi,

how to to index computed/scripted fields in elasticsearch?  
i see from documentation that it is possible to run scripts on update and  
query, but i cant find anything about indexing  
feels like it will be quite useful feature

the problem i have is, that im trying to index json document that have  
latitude and longitude as 2 separate fields, for example:

{  
"title" : "some title",  
"description" : "some description",  
"latitude" : 53.32,  
"longitude" : -6.12  
}

and i want to index it into geo\_point field in elasticsearch  
i will like to avoid any transformations of the document before indexing  
(as i pull json objects from external source and index them into  
elasticsearch without "understanding" the document structure)

so what im looking for is to be able to define mapping for that field like  
that:

"mappings" :  
{  
"comment" :  
{  
"properties" :  
{  
"latitude" : { "type" : "float" },  
"longitude" : { "type" : "float" },  
\* "location" :  
\*

- 

```
   { *

```

- 

```
       "type" : "geo_point", *

```

- "script" : "doc['latitude'].value + ' ,' + doc['longitude'].value'"\*
- 

```
   }*

```

}  
}  
}

is it possible with elasticsearch ?

thx,

--  
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:** ![Karol\_Gwaj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karol_gwaj/32/1324_2.png) [@Karol\_Gwaj](https://discuss.elastic.co/u/Karol_Gwaj)\
**Post date:** [November 13, 2013, 12:07am UTC](https://discuss.elastic.co/t/indexing-computed-scripted-fields/13956/2 "2013-11-13T00:07:25Z")

</div>

just in case someone else will have similar problem,  
i created elasticsearch plugin for handling computed fields:

> **[GitHub - SkillPages/elasticsearch-computed-fields: Computed fields plugin for...](https://github.com/SkillPages/elasticsearch-computed-fields)**
>
> Computed fields plugin for ElasticSearch http://www.elasticsearch.org - GitHub - SkillPages/elasticsearch-computed-fields: Computed fields plugin for ElasticSearch http://www.elasticsearch.org

Cheers,

On Tuesday, October 15, 2013 6:36:05 PM UTC+1, Karol Gwaj wrote:

> Hi,
> 
> how to to index computed/scripted fields in elasticsearch?  
> i see from documentation that it is possible to run scripts on update and  
> query, but i cant find anything about indexing  
> feels like it will be quite useful feature
> 
> the problem i have is, that im trying to index json document that have  
> latitude and longitude as 2 separate fields, for example:
> 
> {  
> "title" : "some title",  
> "description" : "some description",  
> "latitude" : 53.32,  
> "longitude" : -6.12  
> }
> 
> and i want to index it into geo\_point field in elasticsearch  
> i will like to avoid any transformations of the document before indexing  
> (as i pull json objects from external source and index them into  
> elasticsearch without "understanding" the document structure)
> 
> so what im looking for is to be able to define mapping for that field like  
> that:
> 
> "mappings" :  
> {  
> "comment" :  
> {  
> "properties" :  
> {  
> "latitude" : { "type" : "float" },  
> "longitude" : { "type" : "float" },
> 
> - "location" : \*
> - 
> 
> ```
> { *
> 
> ```
> 
> - 
> 
> ```
> "type" : "geo_point", *
> 
> ```
> 
> - "script" : "doc['latitude'].value + ' ,' + doc['longitude'].value'"\*
> - 
> 
> ```
> }*
> 
> ```
> 
> }  
> }  
> }
> 
> is it possible with elasticsearch ?
> 
> thx,

--  
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:** ![Maziyar\_Panahi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maziyar_panahi/32/1584_2.png) [@Maziyar\_Panahi](https://discuss.elastic.co/u/Maziyar_Panahi)\
**Post date:** [May 11, 2014, 9:43am UTC](https://discuss.elastic.co/t/indexing-computed-scripted-fields/13956/3 "2014-05-11T09:43:54Z")

</div>

So this is not possible right? It would be really easy to have such a  
feature in our mappings.

On Wednesday, 16 October 2013 01:36:05 UTC+8, Karol Gwaj wrote:

> Hi,
> 
> how to to index computed/scripted fields in elasticsearch?  
> i see from documentation that it is possible to run scripts on update and  
> query, but i cant find anything about indexing  
> feels like it will be quite useful feature
> 
> the problem i have is, that im trying to index json document that have  
> latitude and longitude as 2 separate fields, for example:
> 
> {  
> "title" : "some title",  
> "description" : "some description",  
> "latitude" : 53.32,  
> "longitude" : -6.12  
> }
> 
> and i want to index it into geo\_point field in elasticsearch  
> i will like to avoid any transformations of the document before indexing  
> (as i pull json objects from external source and index them into  
> elasticsearch without "understanding" the document structure)
> 
> so what im looking for is to be able to define mapping for that field like  
> that:
> 
> "mappings" :  
> {  
> "comment" :  
> {  
> "properties" :  
> {  
> "latitude" : { "type" : "float" },  
> "longitude" : { "type" : "float" },
> 
> - "location" : \*
> - 
> 
> ```
> { *
> 
> ```
> 
> - 
> 
> ```
> "type" : "geo_point", *
> 
> ```
> 
> - "script" : "doc['latitude'].value + ' ,' + doc['longitude'].value'"\*
> - 
> 
> ```
> }*
> 
> ```
> 
> }  
> }  
> }
> 
> is it possible with elasticsearch ?
> 
> thx,

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/1684c0fe-9175-443f-a9b5-570660d7c0b9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/1684c0fe-9175-443f-a9b5-570660d7c0b9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:30am UTC](https://discuss.elastic.co/t/indexing-computed-scripted-fields/13956/4 "2017-07-06T01:30:18Z")

</div>


