Last active
March 4, 2016 08:29
-
-
Save hadashiA/8f8cd979286655380312 to your computer and use it in GitHub Desktop.
Elasticsearchを使ってレコメンデーションする ref: http://qiita.com/hadashiA/items/9a418df95f8611c041a2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ plugin --url 'https://github.com/f-kubotar/elasticsearch-flavor/releases/download/v0.0.2/elasticsearch-flavor-0.0.3.zip' --install flavor |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPOST localhost:9200/my_index -d '{ | |
"mappings" : { | |
"preference" : { | |
"preference": { | |
"properties": { | |
"user_id": { | |
"type": "long" | |
}, | |
"item_id": { | |
"type": "long" | |
}, | |
"value": { | |
"type": "float" | |
} | |
} | |
} | |
} | |
} | |
}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XPOST 'localhost:9200/my_index/preference/1:101/_update' -d '{ | |
"script" : "ctx._source.value += value", | |
"params" : { | |
"user_id" : 1, | |
"item_id": 101, | |
"value": 1 | |
} | |
}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl 'localhost:9200/my_index/preference/_flavor/similar_items/5803?size=3&similarity=EuclideanDistanceSimilarity' | |
HTTP/1.1 200 OK | |
Content-Length: 126 | |
Content-Type: application/json; charset=UTF-8 | |
{ | |
"hits": { | |
"hits": [ | |
{ | |
"item_id": 40891, | |
"value": 1.0 | |
}, | |
{ | |
"item_id": 48541, | |
"value": 1.0 | |
}, | |
{ | |
"item_id": 151, | |
"value": 1.0 | |
} | |
], | |
"total": 3 | |
}, | |
"took": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment