# \[hadoop\] Store GeoJson using PIG

**URL:** <https://discuss.elastic.co/t/hadoop-store-geojson-using-pig/15569>\
**Category:** Elasticsearch\
**Created:** [February 3, 2014, 7:49pm UTC](https://discuss.elastic.co/t/hadoop-store-geojson-using-pig/15569 "2014-02-03T19:49:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dumitru\_Pascu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dumitru_pascu/32/1773_2.png) [@Dumitru\_Pascu](https://discuss.elastic.co/u/Dumitru_Pascu)\
**Post date:** [February 3, 2014, 7:49pm UTC](https://discuss.elastic.co/t/hadoop-store-geojson-using-pig/15569/1 "2014-02-03T19:49:10Z")

</div>

How can I store GeoJson using PIG?

I tried to use TOBAG(lon, lat), however I got in the location stored in the  
following form:

location: [  
{  
0: 23.80323889  
}  
{  
0: 44.31903611  
}  
]

Regards,  
Dumitru

--  
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/56fa268b-d3be-499f-a93d-b49e74779208%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/56fa268b-d3be-499f-a93d-b49e74779208%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Dumitru\_Pascu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dumitru_pascu/32/1773_2.png) [@Dumitru\_Pascu](https://discuss.elastic.co/u/Dumitru_Pascu)\
**Post date:** [February 5, 2014, 6:30pm UTC](https://discuss.elastic.co/t/hadoop-store-geojson-using-pig/15569/2 "2014-02-05T18:30:20Z")

</div>

Anyone tried this before?

Regards,  
Dumitru

On Monday, February 3, 2014 9:49:10 PM UTC+2, Dumitru Pascu wrote:

> How can I store GeoJson using PIG?
> 
> I tried to use TOBAG(lon, lat), however I got in the location stored in  
> the following form:
> 
> location: [  
> {  
> 0: 23.80323889  
> }  
> {  
> 0: 44.31903611  
> }  
> ]
> 
> Regards,  
> Dumitru

--  
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/0d4c090b-8ae3-4a00-bf11-8cbf8a4b5da0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d4c090b-8ae3-4a00-bf11-8cbf8a4b5da0%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![costin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/costin/32/44950_2.png) [@costin](https://discuss.elastic.co/u/costin)\
**Post date:** [February 26, 2014, 10:07pm UTC](https://discuss.elastic.co/t/hadoop-store-geojson-using-pig/15569/3 "2014-02-26T22:07:59Z")

</div>

Can you post your Pig script and your index mapping? Note that for non-native types (Pig doesn't support IP or geo) you  
should define the mapping in advanced in ES since es-hadoop will map it as strings as otherwise.

On 2/5/2014 8:30 PM, Dumitru Pascu wrote:

> Anyone tried this before?
> 
> Regards,  
> Dumitru
> 
> On Monday, February 3, 2014 9:49:10 PM UTC+2, Dumitru Pascu wrote:
> 
> ```
> How can I store GeoJson using PIG?
> 
> I tried to use TOBAG(lon, lat), however I got in the location stored in the following form:
> 
> location: [
> {
> 0: 23.80323889
> }
> {
> 0: 44.31903611
> }
> ]
> 
> Regards,
> Dumitru
> 
> ```
> 
> --  
> 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/0d4c090b-8ae3-4a00-bf11-8cbf8a4b5da0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/0d4c090b-8ae3-4a00-bf11-8cbf8a4b5da0%40googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Costin

--  
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/530E65BF.8040503%40gmail.com](https://groups.google.com/d/msgid/elasticsearch/530E65BF.8040503%40gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Dumitru\_Pascu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dumitru_pascu/32/1773_2.png) [@Dumitru\_Pascu](https://discuss.elastic.co/u/Dumitru_Pascu)\
**Post date:** [March 1, 2014, 2:34pm UTC](https://discuss.elastic.co/t/hadoop-store-geojson-using-pig/15569/4 "2014-03-01T14:34:25Z")

</div>

Index mapping (defined before running the PIG script):

curl -XPOST localhost:9200/location -d '{  
"mappings" : {  
"cell" : {  
"properties" : {  
"mapLocation" : {"type" : "geo\_point" },  
"name" : {"type" : "string"}  
}  
}  
}  
}'

PIG script:

location = load '/user/root/locations/cells\_location.txt' USING  
PigStorage('|') as (name: chararray, latitude: double, longitude: double);  
locationToStore = FOREACH location GENERATE name, TOBAG(longitude,  
latitude) as mapLocation;  
STORE locationToStore INTO 'location/cell' USING  
org.elasticsearch.hadoop.pig.EsStorage();

For the last test I used elasticsearch-hadoop-1.3.0.M2.jar

Thanks!  
Dumitru

On Thu, Feb 27, 2014 at 12:07 AM, Costin Leau [costin.leau@gmail.com](mailto:costin.leau@gmail.com) wrote:

> Can you post your Pig script and your index mapping? Note that for  
> non-native types (Pig doesn't support IP or geo) you should define the  
> mapping in advanced in ES since es-hadoop will map it as strings as  
> otherwise.
> 
> On 2/5/2014 8:30 PM, Dumitru Pascu wrote:
> 
> > Anyone tried this before?
> > 
> > Regards,  
> > Dumitru
> > 
> > On Monday, February 3, 2014 9:49:10 PM UTC+2, Dumitru Pascu wrote:
> > 
> > ```
> > How can I store GeoJson using PIG?
> > 
> > I tried to use TOBAG(lon, lat), however I got in the location stored
> > 
> > ```
> > 
> > in the following form:
> > 
> > ```
> > location: [
> > {
> > 0: 23.80323889
> > }
> > {
> > 0: 44.31903611
> > }
> > ]
> > 
> > Regards,
> > Dumitru
> > 
> > ```
> > 
> > --  
> > 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/0d4c090b-](https://groups.google.com/d/msgid/elasticsearch/0d4c090b-)  
> > 8ae3-4a00-bf11-8cbf8a4b5da0%[40googlegroups.com](http://40googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).
> 
> --  
> Costin
> 
> --  
> You received this message because you are subscribed to a topic in the  
> Google Groups "elasticsearch" group.  
> To unsubscribe from this topic, visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> topic/elasticsearch/3XWKWd-XiPk/unsubscribe.  
> To unsubscribe from this group and all its topics, 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/](https://groups.google.com/d/)  
> msgid/elasticsearch/530E65BF.8040503%[40gmail.com](http://40gmail.com).
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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/CAPUuK1YHLXOh7iP6NiCJQv64m3kva3bitr1S3OTmB1htLpgaUQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAPUuK1YHLXOh7iP6NiCJQv64m3kva3bitr1S3OTmB1htLpgaUQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:46am UTC](https://discuss.elastic.co/t/hadoop-store-geojson-using-pig/15569/5 "2017-07-06T01:46:21Z")

</div>


