Is there any way to score nested documents as if they're native fields of the main document?

Is it possible to get similar scoring methodologies for nested document fields normal fields?

See searches for "awful" (nested) and "amazing" (direct) below.

DELETE /testindex

PUT /testindex
{
  "mappings": {
    "properties": {
      "nestedSummaries": {
        "type": "nested" 
      }
    }
  }
}


PUT testindex/_doc/1
{
  "summaries" : [
    "This movie is amazing",
    "This movie is really amazing",
    "This movie is the most amazing thing that I've seen"  
  ],
  "nestedSummaries" : [
    {
      "text" : "This movie is awful"
    },
    {
      "text" : "This movie is really awful"
    },
    {
      "text" : "This movie is the most awful thing that I've seen"
    }
  ]
}

PUT testindex/_doc/2
{
  "summaries" : [
    "This movie is amazing",
    "This movie is really amazing",
    "This movie is the most amazing thing that I've seen"  
  ],
  "nestedSummaries" : [
    {
      "text" : "This movie is awful"
    },
    {
      "text" : "This movie is really awful"
    },
    {
      "text" : "This movie is the most awful thing that I've seen"
    }
  ]
}

GET testindex/_search?explain=true
{
  "query": {
    "simple_query_string": {
      "query": "amazing"
    }
  }  
}

GET testindex/_search?explain=true
{
  "query": {
     "nested": {
      "path": "nestedSummaries",
      
      "query": {
        "simple_query_string": {
          "query": "awful"
        }
      },
      "score_mode": "sum"
    }
  }  
}

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