# Field\_value\_factor on a nested field value

**URL:** <https://discuss.elastic.co/t/field-value-factor-on-a-nested-field-value/29928>\
**Category:** Elasticsearch\
**Created:** [September 24, 2015, 4:33pm UTC](https://discuss.elastic.co/t/field-value-factor-on-a-nested-field-value/29928 "2015-09-24T16:33:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![el\_cristobal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/el_cristobal/32/4927_2.png) [@el\_cristobal](https://discuss.elastic.co/u/el_cristobal)\
**Post date:** [September 24, 2015, 4:33pm UTC](https://discuss.elastic.co/t/field-value-factor-on-a-nested-field-value/29928/1 "2015-09-24T16:33:17Z")

</div>

Hi - I have an index with a nested array of objects that represent how tenants (in a multitenant app) relate to each item, and I want to boost (I'm thinking via field\_value\_factor?) using values in those fields. So, example data:

```
{
  id: "1",
  body: "document content #1",
  tenant_stats: [
    {
      tenant_id: 1,
      views: 245
    },
    {
      tenant_id: 2,
      views: 145
    }
  ]
},
{
  id: "2",
  body: "document content #2",
  tenant_stats: [
    {
      tenant_id: 1,
      views: 43
    },
    {
      tenant_id: 2,
      views: 5789
    }
  ]
}

```

So in this case I'd want to make queries from tenant 1 prioritize document 1 above 2, since it has more views from them and is therefore more popular, and vice versa for tenant 2. Is this easily doable?

Thanks!

---

<div class="post-metadata">

**Author:** ![msimos](https://avatars.discourse-cdn.com/v4/letter/m/bb73d2/32.png) [@msimos](https://discuss.elastic.co/u/msimos)\
**Post date:** [September 24, 2015, 10:24pm UTC](https://discuss.elastic.co/t/field-value-factor-on-a-nested-field-value/29928/2 "2015-09-24T22:24:35Z")

</div>

Yes you want to use field\_value\_factor using views to boost the score. You may want to use nested documents, if you want to keep the relevance between tenant\_id and views. See this recent post about a similar question:

> [@Nested value on function score](https://discuss.elastic.co/t/nested-value-on-function-score/29935/2):
>
> You'd want to do something like this and you may want to consider using field value factor: [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-field-value-factor](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-field-value-factor) { "query": { "filtered": { "query": { "nested": { "path": "reviews", "query": { "function\_score": { "query": { "term": { "reviews.userId": { "value": "1" …

---

<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 5, 2017, 11:48pm UTC](https://discuss.elastic.co/t/field-value-factor-on-a-nested-field-value/29928/3 "2017-07-05T23:48:10Z")

</div>


