I'm getting weird NullPointerExceptions as soon as I try to use a script 
with a for-loop over nested values. Through some tests I am sure that the 
variable "doc[...].values" I'm retrieving is of type "Longs". Adding any 
kind of null-checks did not fix this problem so I suppose it's a bug in 
elasticsearch...

Mapping:
{
  "ppint" : {
    "mappings" : {
      "version" : {
        "_meta" : {
          "model" : "...."
        },
        "properties" : {
          "classes" : { "type" : "string" },
          "codeTags" : {
            "type" : "nested",
            "properties" : {
              "count" : { "type" : "integer" },
              "name" : { "type" : "string" }
            }
          },
          "languages" : { "type" : "string" },
          "name" : { "type" : "string" },
          "namespaces" : { "type" : "string" },
          "package" : {
            "properties" : {
              "description" : { "type" : "string" },
              "id" : { "type" : "string" },
              "name" : { "type" : "string" }
            }
          }
        }
      }
    }
  }
}

Query:
{
    "query": {
        "function_score": {
            "score_mode": "first",
            "functions": [
                {
                    "script_score": {
                        "script": "for (tag : doc['codeTags.count'].values) 
{  _score + tag; }"
                    }
                }
            ]
        }
    }
}

Error:
{
    [aF4-pJ4-RuuqrYV9SCHmnQ][ppint][4]: QueryPhaseExecutionException [
        [ppint][4]: query [
            filtered (
                function score (
                    ConstantScore(*:*),
                    functions: [
                        {
                            filter(*:*),
                            function [
                                script [
                                    for (tag : doc['codeTags.count'].values) 
{  _score + tag; }
                                ],
                                params [
                                    null
                                ]
                            ]
                        }
                    ]
                )
            )->cache(_type:version)
        ],
        from[0],
        size[10]: Query Failed [Failed to execute main query]
    ];
    nested: NullPointerException;
}

I hope you can help me with that problem.
I really need the score to be dependent based on tag-count , or I would 
have to move to some other system than elasticsearch.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/a37b8116-12e5-480c-b3e4-1c36a84a36c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to