# MLT query delivering strange results

**URL:** <https://discuss.elastic.co/t/mlt-query-delivering-strange-results/20866>\
**Category:** Elasticsearch\
**Created:** [November 20, 2014, 11:39am UTC](https://discuss.elastic.co/t/mlt-query-delivering-strange-results/20866 "2014-11-20T11:39:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel\_kummer](https://avatars.discourse-cdn.com/v4/letter/d/c4cdca/32.png) [@daniel\_kummer](https://discuss.elastic.co/u/daniel_kummer)\
**Post date:** [November 20, 2014, 11:39am UTC](https://discuss.elastic.co/t/mlt-query-delivering-strange-results/20866/1 "2014-11-20T11:39:37Z")

</div>

I have been trying to figure out how exactly the more\_like\_this query  
behaves. The doc says "Under the hood, more\_like\_this simply creates  
multiple should clauses in a bool query of interesting terms extracted from  
some provided text." But I found several examples that I could not explain.  
This one illustrates it:

I am using elasticsearch-1.4.0. I am creating an index like this (no  
mapping defined before):  
curl -XPUT 'localhost:9200/twitter/tweet/1' -d '{"user" : "user1",  
"message" : "aaa"}'  
curl -XPUT 'localhost:9200/twitter/tweet/2' -d '{"user" : "user1",  
"message" : "aaa bbb"}'  
curl -XPUT 'localhost:9200/twitter/tweet/3' -d '{"user" : "user1",  
"message" : "bbb aaa"}'  
curl -XPUT 'localhost:9200/twitter/tweet/4' -d '{"user" : "user2",  
"message" : "bbb"}'  
curl -XPUT 'localhost:9200/twitter/tweet/5' -d '{"user" : "user2",  
"message" : "aaa bbb"}'  
curl -XPUT 'localhost:9200/twitter/tweet/6' -d '{"user" : "user2",  
"message" : "bbb aaa"}'

Then I query it:  
curl -XGET  
'[http://localhost:9200/twitter/tweet/\_search?pretty=true&size=10](http://localhost:9200/twitter/tweet/_search?pretty=true&size=10)' -d '{  
"query": {  
"more\_like\_this\_field": {  
"message": {  
"like\_text": "aaa bbb",  
"percent\_terms\_to\_match": 1,  
"min\_term\_freq": 1,  
"max\_query\_terms": 3,  
"min\_doc\_freq": 1  
}  
}  
}  
}  
{  
"took" : 3,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 5,  
"max\_score" : 14.4000225,  
"hits" : [ {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "4",  
"\_score" : 14.4000225,  
"\_source":{"user" : "user2", "message" : "bbb"}  
}, {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "2",  
"\_score" : 12.729599,  
"\_source":{"user" : "user1", "message" : "aaa bbb"}  
}, {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "5",  
"\_score" : 12.72813,  
"\_source":{"user" : "user2", "message" : "aaa bbb"}  
}, {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "3",  
"\_score" : 12.728111,  
"\_source":{"user" : "user1", "message" : "bbb aaa"}  
}, {  
"\_index" : "twitter",  
"\_type" : "tweet",  
"\_id" : "6",  
"\_score" : 12.5501995,  
"\_source":{"user" : "user2", "message" : "bbb aaa"}  
} ]  
}  
}

So text 1 "aaa" is missing. I get the same result if I use "like\_text":  
"bbb aaa" in the above query. However, if I use "like\_text": "aaa" I get  
what I would expect: All texts except "bbb" are returned.

What kind of should-query is generated by more\_like\_this in the above  
example? I would have expected:  
curl -XGET  
'[http://localhost:9200/twitter/tweet/\_search?pretty=true&size=10](http://localhost:9200/twitter/tweet/_search?pretty=true&size=10)' -d '{  
"query": {  
"bool": {  
"should": [  
{  
"match": {  
"message": "aaa"  
}  
},  
{  
"match": {  
"message": "bbb"  
}  
}  
],  
"minimum\_should\_match": 2  
}  
}  
}'  
but this obviously returns neither "aaa" nor "bbb".

Why does the above more\_like\_this query return "bbb" but not "aaa"?

--  
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 [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/53fae773-9359-4a1a-980e-a42d1dfd6d0f%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/53fae773-9359-4a1a-980e-a42d1dfd6d0f%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:48am UTC](https://discuss.elastic.co/t/mlt-query-delivering-strange-results/20866/2 "2017-07-06T00:48:43Z")

</div>


