I have the following document schema

authorid: 1
athorName: joshua bloch
books: [
{
bookId: 100
bookName: effective java
sales: 200
},
{
bookId: 101
bookName: Java Puzzlers
sales: 100
}
]
sellerTags: ["java book", "effective java", "joshua bloch"]

'books' is a nested field in the above schema. I am trying to access that 
nested field in a script inside a function query, but something is going 
wrong.

{
    "explain": true, 
   "query": {
      "function_score": {
         "boost_mode": "replace",
         "query": {
            "match": { "sellerTags":"java book"}
         },
         "script_score": {             
            "params": {
               "param1": 2
            },
             "script": "doc['books.sales'].value * param1 "
         }
      }
   }
}

Though each document returned has sales in the index, I get a score of 0 
for both the documents i have (I have got one more document that matches 
the query). If it is helpful here is a part of explain string that shows 
that script is making the score as 0

"details": [
                        {
                           "value": 0,
                           "description": "script score function: composed 
of:",
                           "details": [
                              {
                                 "value": 3.5981894,
                                 "description": "sum of:",
                                 "details": [ ...PerFieldSimilarity...]
                              } ]



Can some one point out the mistake in my query. Why do i get the score as 0 
and how to fix it ?

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/e9fd5575-cd66-4fe0-a788-b6c9b1e98ed0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to