# What's the difference: IndexRequest set Source by string or by byte\[\]

**URL:** <https://discuss.elastic.co/t/whats-the-difference-indexrequest-set-source-by-string-or-by-byte/11856>\
**Category:** Elasticsearch\
**Created:** [May 7, 2013, 2:51pm UTC](https://discuss.elastic.co/t/whats-the-difference-indexrequest-set-source-by-string-or-by-byte/11856 "2013-05-07T14:51:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Qinghui\_Xu](https://avatars.discourse-cdn.com/v4/letter/q/e68b1a/32.png) [@Qinghui\_Xu](https://discuss.elastic.co/u/Qinghui_Xu)\
**Post date:** [May 7, 2013, 2:51pm UTC](https://discuss.elastic.co/t/whats-the-difference-indexrequest-set-source-by-string-or-by-byte/11856/1 "2013-05-07T14:51:15Z")

</div>

Hello, I have a question about the source used for indexation.  
The elasticsearch IndexRequest API provides both setSource(String) and  
setSource(byte[]), the java doc of the first one says it's preferable to  
use the second.

So what's the advantage to set source by byte array instead of by string?  
Is there some consideration of performance or of encoding format  
consistency?

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:** ![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:37am UTC](https://discuss.elastic.co/t/whats-the-difference-indexrequest-set-source-by-string-or-by-byte/11856/2 "2017-07-06T02:37:56Z")

</div>

Closed on July 6, 2017, 2:37am UTC


