# Native script, doc, fields, source - which on fits best?

**URL:** <https://discuss.elastic.co/t/native-script-doc-fields-source-which-on-fits-best/14464>\
**Category:** Elasticsearch\
**Created:** [November 19, 2013, 10:01am UTC](https://discuss.elastic.co/t/native-script-doc-fields-source-which-on-fits-best/14464 "2013-11-19T10:01:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yann\_Barraud](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yann_barraud/32/1108_2.png) [@Yann\_Barraud](https://discuss.elastic.co/u/Yann_Barraud)\
**Post date:** [November 19, 2013, 10:01am UTC](https://discuss.elastic.co/t/native-script-doc-fields-source-which-on-fits-best/14464/1 "2013-11-19T10:01:35Z")

</div>

Hi,

I am currently updating my entity resolution plugin. I was comparing docs  
based on doclookup (doc()). Seems it is wrong from a functional point of  
view. I have to switch, and I'm now wondering :

- should I use sourceLookup (source()) or fieldsLookup (fields()) ?
- if fields, how can I do (I tried, but failed) ? Any example ?

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-scripting.html)  
is not cristal cleear to me.

Thanks.

Yann

--  
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:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [November 19, 2013, 3:52pm UTC](https://discuss.elastic.co/t/native-script-doc-fields-source-which-on-fits-best/14464/2 "2013-11-19T15:52:50Z")

</div>

Yann,

Some good documentation on mvel is here:

[http://mvel.codehaus.org/MVEL%202.0%20Portal](http://mvel.codehaus.org/MVEL%202.0%20Portal)

This post inspired my own example mvel script as part of a combinatorial  
hierarchy facet "add-on" I wrote. It shows a simple example that is glued  
into ES and accesses the fields that are stored by ES within \_source:

[http://elasticsearch-users.115913.n3.nabble.com/facet-and-grouping-td4020055.html](http://elasticsearch-users.115913.n3.nabble.com/facet-and-grouping-td4020055.html)

Hope this helps!

Brian

--  
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:06am UTC](https://discuss.elastic.co/t/native-script-doc-fields-source-which-on-fits-best/14464/3 "2017-07-06T02:06:12Z")

</div>


