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
def dictsorted(dic, valuesort=False): | |
if valuesort: | |
return [(k, v) for k, v in sorted(d.items(), key=lambda x:x[1])] | |
return [(k, v) for k, v in sorted(d.items())] | |
if __name__ == '__main__': | |
d = {'A':500, 'C':300, 'D':100, 'E':400, 'B':200} | |
print dictsorted(d, False) | |
print dictsorted(d, True) |
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
<!-- Add the following lines to theme's html code right before </head> --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
<!-- | |
Usage: just add <div class="gist">[gist URL]</div> | |
Example: <div class="gist">https://gist.github.com/1395926</div> | |
--> |
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
{ | |
"japanese_template": { | |
"template": "*ja", | |
"settings": { | |
"analysis": { | |
"filter": { | |
"romaji": { | |
"type": "kuromoji_readingform", | |
"use_romaji": true | |
} |
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 -XPUT 'localhost:9200/medium/blog/1' -d '{ | |
"title": "Elasticsearch 特徴まとめ", | |
"description": "Elasticsearch Features — 主にシステムを中心とした特徴まとめ", | |
"creator": "Kunihiko Kido", | |
"link": "https://medium.com/hello-elasticsearch/elasticsearch-500996e47c70", | |
"tags": ["Elasticsearch"], | |
"pubDate": "2014-03-12T11:09" | |
}' | |
curl -XPUT 'localhost:9200/medium/blog/2' -d '{ |
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
# -*- coding: utf-8 -*- | |
from __future__ import print_function, unicode_literals | |
import json | |
import boto3 | |
import logging | |
from elasticsearch import Elasticsearch | |
from elasticsearch import helpers | |
from elasticsearch.exceptions import ElasticsearchException |
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
{ | |
"category": "サッカー", | |
"query": { | |
"bool": { | |
"should": [{ | |
"simple_query_string": { | |
"fields": ["text"], | |
"default_operator": "or", | |
"query": "\"サッカー\" " | |
} |
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
{ | |
"took": 8883, | |
"timed_out": false, | |
"_shards": { | |
"total": 90, | |
"successful": 90, | |
"failed": 0 | |
}, | |
"hits": { | |
"total": 2811, |
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
{ | |
"query": { | |
"bool": { | |
"must": [{ | |
"simple_query_string": { | |
"query": "\"サッカー\"", // 1) 人が与える任意の分類・キーワード | |
"fields": ["text"] // 2) 検索対象フィールド | |
} | |
}], | |
"filter": [{ |
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
{ | |
"doc": { | |
"text": "スターウォーズのスター・デストロイヤー型ドローン動画が話題に" | |
}, | |
"aggs": { | |
"categories": { | |
"terms": { | |
"field": "category" | |
} | |
} |