# Hashmaps in params

**URL:** <https://discuss.elastic.co/t/hashmaps-in-params/92763>\
**Category:** Elasticsearch\
**Created:** [July 12, 2017, 6:36am UTC](https://discuss.elastic.co/t/hashmaps-in-params/92763 "2017-07-12T06:36:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silas\_Hansen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/silas_hansen/32/67521_2.png) [@Silas\_Hansen](https://discuss.elastic.co/u/Silas_Hansen)\
**Post date:** [July 12, 2017, 6:36am UTC](https://discuss.elastic.co/t/hashmaps-in-params/92763/1 "2017-07-12T06:36:43Z")

</div>

I'm trying to send a list of lookup-values as parameters to a function\_score script.

I'm trying to supply the script with a map of ID's that it will use to lookup the current documentId and use whatever value exists in the map for some calculation.

This is somewhat what i'm trying to do, but of course it doesn't compile.

ES 5.3.2

```
{
  "query": {
	"function_score": {
		  "script_score": {
			"script" : {
					"params": {
						"mapValues": { 
						  "A": 1.5, //Custom value for document with ID=A
						  "B": 1.6, //Custom value for document with ID=B
						  "C": 1.7 //Custom value for document with ID=C
						}
					},
					"inline": "def mapValue = params.mapValues.get(doc.Id); /* Do something */ "
			}
		  }
		}
  }
}

```

I know I could just use two arras and a loop (one with ids and another with values), but that would require the array to be iterated for every document, which is not optimal for performance reasons.

Does painless support any type of complex objects as parameters?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 12, 2017, 4:37pm UTC](https://discuss.elastic.co/t/hashmaps-in-params/92763/2 "2017-07-12T16:37:01Z")

</div>

Hm, painless should support maps/objects like that (I've done similar in the past). What compile error are you getting?

---

<div class="post-metadata">

**Author:** ![Silas\_Hansen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/silas_hansen/32/67521_2.png) [@Silas\_Hansen](https://discuss.elastic.co/u/Silas_Hansen)\
**Post date:** [July 13, 2017, 11:21am UTC](https://discuss.elastic.co/t/hashmaps-in-params/92763/3 "2017-07-13T11:21:07Z")

</div>

I'm glad you asked me to give you the compile error, because it turned out that it's actually working as expected. I have no idea what was wrong with my setup before.

Anyways, thank you for at least taking the time to answer, otherwise I would have dropped the idea completely 😄

---

<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:** [August 10, 2017, 11:21am UTC](https://discuss.elastic.co/t/hashmaps-in-params/92763/4 "2017-08-10T11:21:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
