More like this not working

Hi, following the more like this api document, I cannot get any returns even when I pass an exact term for search. Below is my code.

PUT /test
{
"mappings": {
        "properties": {
            "title": {
                "type": "text",
                "term_vector": "yes"
            },
            "description": {
                "type": "text"
            },
            "tags": {
                "type": "text",
                "fields" : {
                    "raw": {
                        "type" : "text",
                        "analyzer": "keyword",
                        "term_vector" : "yes"
                    }
                }
            }
        }
    }
}

POST /test/_doc
{
  "title":"test title",
  "description":"test description",
  "tag":"test tag"
}

GET /test/_search
{
"query": {
    "more_like_this" : {
        "fields" : ["title", "description"],
        "like" : "test",
        "min_term_freq" : 1,
        "max_query_terms" : 12
    }
}
}

GET /test/_search
{
"query": {
    "more_like_this" : {
        "fields" : ["title", "description"],
        "like" : "test title",
        "min_term_freq" : 1,
        "max_query_terms" : 12
    }
}
}

Hi Rick.

It's fussy about not having super-rare indexed terms too. Ordinarily "more" would mean using words that are known to exist in documents other than your example one. So for your example you'll need to add

"min_doc_freq": 1

To take more control over how matching works you might be interested in this alternative recently added to the docs.

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