More Like This Query - Not Working?


(Garrett Johnson) #1

I'm using an mlt query to query for other documents that are like a document in a type.

When I query however I'm not getting results I would expect.

Below is looking for documents of a similar to "MyType" document ID #LONGIDSTRINGABC123 but when I run the search sometimes it comes back with multiple types and sometimes it does not. In this case it is finding lots of MyType documents but none of other types.

I think what is happening is I am limiting to 250 results and all 250 are in "MyType" but I want it to only find 25 in "MyType" and get as many as 25 from any other type that may be similar. Am I doing something wrong with my aggs? I've also fiddled around with min_term_frequency and max_query_terms and no tweaking helps.

Example of my query:

{
"query": {
"more_like_this": {
"fields": [
"Email",
"Name",
"LastName",
"Phone",
"Identifier",
"PostalCode",
"AccountName",
"Street",
"Website",
"City",
"Company",
"Notes"
],
"docs": [
{
"_index": "jdbc",
"_type": "MyType",
"_id": "LONGIDSTRINGABC123"
}
],
"min_term_freq": 1,
"max_query_terms": 60,
"stop_words": [
"Install",
"Site",
"Site",
"Purchased"
]
}
},
"from": 0,
"size": 250,
"aggs": {
"top_types": {
"terms": {
"field": "_type"
},
"aggs": {
"top_type_hits": {
"top_hits": {
"size": 25
}
}
}
}
}
}


(system) #2