# Like\_text required?

**URL:** <https://discuss.elastic.co/t/like-text-required/6292>\
**Category:** Elasticsearch\
**Created:** [January 5, 2012, 3:22pm UTC](https://discuss.elastic.co/t/like-text-required/6292 "2012-01-05T15:22:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nurikabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nurikabe/32/2192_2.png) [@nurikabe](https://discuss.elastic.co/u/nurikabe)\
**Post date:** [January 5, 2012, 3:22pm UTC](https://discuss.elastic.co/t/like-text-required/6292/1 "2012-01-05T15:22:10Z")

</div>

Quick question from an ElasticSearch newbie.

I notice in the MLT documentation  
([http://www.elasticsearch.org/guide/reference/api/more-like-this.html](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?

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [January 5, 2012, 3:26pm UTC](https://discuss.elastic.co/t/like-text-required/6292/2 "2012-01-05T15:26:53Z")

</div>

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](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?

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

>

---

<div class="post-metadata">

**Author:** ![nurikabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nurikabe/32/2192_2.png) [@nurikabe](https://discuss.elastic.co/u/nurikabe)\
**Post date:** [January 5, 2012, 3:49pm UTC](https://discuss.elastic.co/t/like-text-required/6292/3 "2012-01-05T15:49:46Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [January 5, 2012, 3:57pm UTC](https://discuss.elastic.co/t/like-text-required/6292/4 "2012-01-05T15:57:42Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![nurikabe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nurikabe/32/2192_2.png) [@nurikabe](https://discuss.elastic.co/u/nurikabe)\
**Post date:** [January 5, 2012, 4:01pm UTC](https://discuss.elastic.co/t/like-text-required/6292/5 "2012-01-05T16:01:46Z")

</div>

Got it. Thanks for clarifying.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:43am UTC](https://discuss.elastic.co/t/like-text-required/6292/6 "2017-07-06T03:43:44Z")

</div>


