Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@loren
Created October 29, 2014 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loren/cbc7e95ed9d015e70e4a to your computer and use it in GitHub Desktop.
Save loren/cbc7e95ed9d015e70e4a to your computer and use it in GitHub Desktop.
More like this (MLT) query to group/classify photos into albums
GET http://localhost:9200/development-asis-flickr_photos/_search
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"more_like_this": {
"fields": [
"tags"
],
"ids": [
"12345"
],
"min_term_freq": 1,
"max_query_terms": 500,
"percent_terms_to_match": 0.75
}
},
{
"more_like_this": {
"fields": [
"title"
],
"ids": [
"12345"
],
"min_term_freq": 1,
"max_query_terms": 500,
"percent_terms_to_match": 0.5
}
},
{
"more_like_this": {
"fields": [
"description"
],
"ids": [
"12345"
],
"min_term_freq": 1,
"max_query_terms": 500,
"percent_terms_to_match": 0.8
}
}
]
}
},
"filter": {
"bool": {
"must": [
{
"term": {
"owner": "flickr_user_1@n02"
}
},
{
"term": {
"taken_at": "2012-04-23"
}
}
]
}
}
}
},
"aggregations": {
"scores_histogram": {
"histogram": {
"script": "doc.score",
"interval": 2,
"order": {
"_key": "desc"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment