o19s / elasticsearch-learning-to-rank

Plugin to integrate Learning to Rank (aka machine learning for better relevance) with Elasticsearch
http://opensourceconnections.com/blog/2017/02/14/elasticsearch-learning-to-rank/
Apache License 2.0
1.48k stars 369 forks source link

Error Creating Ranklib Model #382

Closed hansen-young closed 3 years ago

hansen-young commented 3 years ago

Hi, I would like to ask for help in creating model using ranklib. In the documentation and demo, it uses string for model.model.definition. I tried the same thing and get the following error:

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "object mapping for [model.model.definition] tried to parse field [definition] as object, but found a concrete value"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "object mapping for [model.model.definition] tried to parse field [definition] as object, but found a concrete value"
    },
    "status": 400
}

Here is my payload:

POST /_ltr/_featureset/featurename/_createmodel
{
    "model": {
        "name": "model_name",
        "model": {
            "type": "model/ranklib",
            "definition": "## LambdaMART\n## No. of trees = 10000 ..."
        }
    }
}

Detail of ES:

"version" : {
    "number" : "7.12.0",
    "build_flavor" : "default",
    "build_type" : "docker",
    "build_hash" : "78722783c38caa25a70982b5b042074cde5d3b3a",
    "build_date" : "2021-03-18T06:17:15.410153305Z",
    "build_snapshot" : false,
    "lucene_version" : "8.8.0",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
}
worleydl commented 3 years ago

Hello,

The format of your request looks correct. Have you double-checked to confirm everything is being escaped correctly in the definition? If everything looks good can you create a gist of the full request? I haven't seen that particular error before so I'm not certain what the underlying issue is here.

hansen-young commented 3 years ago

I have checked the definition and there is no problem with the escaped characters.

I have also tried the following:

which returns the same response.

I have also tried removing the model metadata (the ## before the actual model definition) and got a different error:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "Error while parsing model [model_name] with type [model/ranklib]"
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "Error while parsing model [model_name] with type [model/ranklib]",
        "caused_by": {
            "type": "rank_lib_error",
            "reason": "java.lang.NullPointerException: Cannot invoke \"ciir.umass.edu.learning.RANKER_TYPE.ordinal()\" because \"type\" is null",
            "caused_by": {
                "type": "null_pointer_exception",
                "reason": "Cannot invoke \"ciir.umass.edu.learning.RANKER_TYPE.ordinal()\" because \"type\" is null"
            }
        }
    },
    "status": 400
}

Here is one of the payload I used (26 features): payload.txt

worleydl commented 3 years ago

Thank you for the additional information. I was able to send the payload off without error, perhaps there is a problem with how you are creating the request?

As a sidenote, the last error you ran into comes from the type being required in the model definition. Since you ran into that it does seem like it's at least picking up on the definition text so I'm still unsure where the underlying issue is here.

hansen-young commented 3 years ago

Hi, I tried a fresh installation of elasticsearch on a different machine and it somehow works. So I guess the problem is on my elasticsearch not with the LTR plugin. Thankyou for you help @worleydl .