# Re: custom\_score and javascript

**URL:** <https://discuss.elastic.co/t/re-custom-score-and-javascript/4812>\
**Category:** Elasticsearch\
**Created:** [July 7, 2011, 3:47pm UTC](https://discuss.elastic.co/t/re-custom-score-and-javascript/4812 "2011-07-07T15:47:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [July 7, 2011, 3:47pm UTC](https://discuss.elastic.co/t/re-custom-score-and-javascript/4812/1 "2011-07-07T15:47:49Z")

</div>

> ```
> "script": "(doc['my_type'].value == 'Contact') ? 2 : 1;"
> 
> ```

Try replacing your ' with \u0027

clint

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [July 8, 2011, 1:05am UTC](https://discuss.elastic.co/t/re-custom-score-and-javascript/4812/2 "2011-07-08T01:05:55Z")

</div>

Thats because you escape in curl the request with '. You should not see that if you call it from the lang of your choice).

On Friday, July 8, 2011 at 3:02 AM, Thomas Witt wrote:

> On 7 Jul., 17:47, Clinton Gormley \<[clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) ([http://iannounce.co.uk](http://iannounce.co.uk))\> wrote:
> 
> > > "script": "(doc['my\_type'].value == 'Contact') ? 2 : 1;"
> > 
> > Try replacing your ' with \u0027
> 
> Oops - that worked. How come? Is that documented anywhere? Why is  
> that?
> 
> Thanks for the help anyway!
> 
> .. Thomas

---

<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, 4:01am UTC](https://discuss.elastic.co/t/re-custom-score-and-javascript/4812/3 "2017-07-06T04:01:20Z")

</div>

Closed on July 6, 2017, 4:01am UTC


