Like_text required?

Quick question from an ElasticSearch newbie.

I notice in the MLT documentation
(http://www.elasticsearch.org/guide/reference/api/more-like-this.html) that
one can request similar documents based only upon a given document with no
other parameters. However when submitting a query, eg:

{

"more_like_this" : {
    "fields" : ["name.first", "name.last"],
    "like_text" : "text like this one",
    "min_term_freq" : 1,
    "max_query_terms" : 12
}

}

then "like_text" is required. Is there any reason like_text is required in this instance? Why not just return similar documents as per the url-only request when like_text is absent?

On Thu, 2012-01-05 at 07:22 -0800, nurikabe wrote:

Quick question from an Elasticsearch newbie.

I notice in the MLT documentation
(Elasticsearch Platform — Find real-time answers at scale | Elastic)
that one can request similar documents based only upon a given
document with no other parameters. However when submitting a query,
eg:

{
"more_like_this" : {
"fields" : ["name.first", "name.last"],
"like_text" : "text like this one",
"min_term_freq" : 1,
"max_query_terms" : 12
}
}

then "like_text" is required. Is there any reason like_text is
required in this instance? Why not just return similar documents as
per the url-only request when like_text is absent?

The URL version of MLT uses a document (whose ID you pass in) to build
the like_text. With the query DSL version, ES can't build the text for
you, so you need to do it yourself

clint

Okay, I guess I'm still confused about URL versus DSL. For some reason I
thought they could be combined, for example something like this:

curl -XGET http://localhost:9200/index/type/6593 -d '{
"query": {
"more_like_this": {

"fields" : ["name.first", "name.last"],

"min_term_freq": 1,
"max_query_terms": 12

}
}'

but I guess that's not the case?

On Thursday, January 5, 2012 10:26:53 AM UTC-5, Clinton Gormley wrote:

The URL version of MLT uses a document (whose ID you pass in) to build
the like_text. With the query DSL version, ES can't build the text for
you, so you need to do it yourself

clint

On Thu, 2012-01-05 at 07:49 -0800, nurikabe wrote:

Okay, I guess I'm still confused about URL versus DSL. For some
reason I thought they could be combined, for example something like
this:

curl -XGET http://localhost:9200/index/type/6593 -d '{
"query": {
"more_like_this": {
"fields" : ["name.first", "name.last"],
"min_term_freq": 1,
"max_query_terms": 12
}
}'

but I guess that's not the case?

No, that won't work. The query DSL is only used if you have _search
where you currently have your doc ID (6593)

clint

Got it. Thanks for clarifying.