# Field value factor with function query in nested object not found

**URL:** <https://discuss.elastic.co/t/field-value-factor-with-function-query-in-nested-object-not-found/65195>\
**Category:** Elasticsearch\
**Created:** [November 7, 2016, 9:56am UTC](https://discuss.elastic.co/t/field-value-factor-with-function-query-in-nested-object-not-found/65195 "2016-11-07T09:56:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Silvestre\_Losada](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@Silvestre\_Losada](https://discuss.elastic.co/u/Silvestre_Losada)\
**Post date:** [November 7, 2016, 9:56am UTC](https://discuss.elastic.co/t/field-value-factor-with-function-query-in-nested-object-not-found/65195/1 "2016-11-07T09:56:01Z")

</div>

HI,

I have a nested object on my mappings with multiple values. Every user has a set of capacities each capacity has a number of points that describes the level of the user in that capacity.

```
{
	"userId": "1",
	"usertype": 2,
	"capacities": [{
		"name": "capacity1",
		"points": 200
	}, {
		"name": "capacity3",
		"points": 400
	}, {
		"name": "capacity2",
		"points": 100
	}]
},
{
	"userId": "2",
	"usertype": 2,
	"capacities": [{
		"name": "capacity1",
		"points": 200
	}, {
		"name": "capacity4",
		"points": 400
	}, {
		"name": "capacity2",
		"points": 100
	}]

}

```

I want to create a query that filter by user type and then rank the result using a set of capacities, I'm trying to use function score with field value factor.

I'm using a query like this, elasticsearch is not able to find the field capacities.point for field value factor.

```
{
    "query": {
		"function_score": {
			"functions": [{
				"filter": {
					"nested": {
						"filter": {
							"term": {
								"capacities.capacity": "capacity2"
							}
						},
						"path": "capacities"
					}
				},
				"field_value_factor": {
					"field": "capacities.point",
					"missing": 1
				}
			},
            {
    			"filter": {
					"nested": {
						"filter": {
							"term": {
								"capacities.capacity": "capacity1"
							}
						},
						"path": "capacities"
					}
				},
				"field_value_factor": {
					"field": "capacities.point",
					"missing": 1
				}
			}],
			"query": {
				"bool": {
					"should": [{
                        ... another query elements that influence on score
					}]
				}
			}
		}
	},
	"filter": {
		"bool": {
			"must": [{
				"terms": {
					"ustertype": [
						2
					]
				}
			}]
		}
	}
}

```

Kind regards.

---

<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:** [December 5, 2016, 9:56am UTC](https://discuss.elastic.co/t/field-value-factor-with-function-query-in-nested-object-not-found/65195/2 "2016-12-05T09:56:17Z")

</div>

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