# Nested value on function score

**URL:** <https://discuss.elastic.co/t/nested-value-on-function-score/29935>\
**Category:** Elasticsearch\
**Created:** [September 24, 2015, 5:22pm UTC](https://discuss.elastic.co/t/nested-value-on-function-score/29935 "2015-09-24T17:22:01Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![besson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/besson/32/15808_2.png) [@besson](https://discuss.elastic.co/u/besson)\
**Post date:** [March 9, 2017, 10:36am UTC](https://discuss.elastic.co/t/nested-value-on-function-score/29935/8 "2017-03-09T10:36:51Z")

</div>

Hello, I have a related question that I couldn't get from the previous discussion.  
I want to boost by a nested object field but a filtered one. Let's say I have this documents:

```
POST /test/doc/1
{
  "title": "doc 1",
  "queries": 
    [
      {
        "hash": "102a",
         "value": 0.9
      },
      {
        "hash": "101a",
       "value": 0.9
      }
    ]
}

POST /test/doc/2
{
  "title": "doc 2",
  "queries": 
    [
      {
        "hash": "102a",
         "value": 1.0
      },
      {
        "hash": "101a",
       "value": 0.8
      }
    ]
}

POST /test/doc/3
{
  "title": "doc 3",
  "queries": 
    [
      {
        "hash": "103a",
         "value": 0.9
      },
      {
        "hash": "101a",
       "value": 0.3
      }
    ]
}

```

I want to match all documents but boost those ones that have a specific hash value:

```
GET /test/doc/_search
{
    "query": {
      "nested": {
        "path": "queries",
        "query": {
          "function_score": {
            "query": { "match_all": {} },
            "functions": [
              {
                "field_value_factor": {
                  "field": "queries.value",
                  "missing": 0
                },
                "filter": {
                    "match": {"queries.hash": "102a"}
                }
              }
            ]
          }
        }
      }
    }
}

```

With this query I expected doc 2, doc1 and doc 3 were returned in this order, given I am using the queries.value for the hash value 102a. However, the result is not that. I have a different order and a constant score of 1 for each document.

Could you please point any mistakes in my query or tell me if is not possible to have this with nested documents in function scores.

thank you!

---

_[View the full topic](https://discuss.elastic.co/t/nested-value-on-function-score/29935)._
