# Elasticsearch mongoDb River + Native Script Plugin

**URL:** <https://discuss.elastic.co/t/elasticsearch-mongodb-river-native-script-plugin/13268>\
**Category:** Elasticsearch\
**Created:** [August 20, 2013, 11:53am UTC](https://discuss.elastic.co/t/elasticsearch-mongodb-river-native-script-plugin/13268 "2013-08-20T11:53:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stefan\_Meiwald](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Stefan\_Meiwald](https://discuss.elastic.co/u/Stefan_Meiwald)\
**Post date:** [August 20, 2013, 11:53am UTC](https://discuss.elastic.co/t/elasticsearch-mongodb-river-native-script-plugin/13268/1 "2013-08-20T11:53:23Z")

</div>

I am currently trying to run a nativescript with the "script" property of  
the river configuration. The script is starting as expected but the problem  
is that doc() is always null and I can't access any fields of the document  
to run my document transformation.

Any idea how to solve this?  
public class LambertToWgs84Script extends AbstractSearchScript {

public static class Factory implements NativeScriptFactory {

```
@Override
public ExecutableScript newScript(@Nullable
                                  Map<String, Object> params) {

  return new LambertToWgs84Script(params);
}

```

}

@Override  
public Object run() {  
// Get xy Values  
Long x = (Long) doc().get(  
"realEstateCommonData.locationDto.geoCoordinateDto.xCoordinate");  
Long y = (Long) doc().get(  
"realEstateCommonData.locationDto.geoCoordinateDto.yCoordinate");

```
// Transformation

// Write Coordinates back
JSONObject newLocation = new JSONObject();
try {
  newLocation.put("Type", "Point");
  JSONArray coords = new JSONArray();
  coords.put("bla");
  coords.put("blub");
  newLocation.put("coordinates", coords);
  doc().put("location", newLocation);
} catch (JSONException e) {
  e.printStackTrace();
}

return true;

```

}  
}

--  
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:** ![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:20am UTC](https://discuss.elastic.co/t/elasticsearch-mongodb-river-native-script-plugin/13268/2 "2017-07-06T02:20:33Z")

</div>


