Skip to content

Instantly share code, notes, and snippets.

@GINK03
Last active February 17, 2021 09:20
Show Gist options
  • Save GINK03/c366a6492d0f3aa174a30265d918c2e4 to your computer and use it in GitHub Desktop.
Save GINK03/c366a6492d0f3aa174a30265d918c2e4 to your computer and use it in GitHub Desktop.
elasticsearch Japanese example
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%%capture\n",
"%pip install watermark"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Last updated: 2021-02-17T18:09:59.587611+09:00\n",
"\n",
"Python implementation: CPython\n",
"Python version : 3.8.3\n",
"IPython version : 7.20.0\n",
"\n",
"Compiler : GCC 9.3.0\n",
"OS : Linux\n",
"Release : 5.8.0-38-generic\n",
"Machine : x86_64\n",
"Processor : x86_64\n",
"CPU cores : 16\n",
"Architecture: 64bit\n",
"\n"
]
}
],
"source": [
"# 1. magic to print version\n",
"# 2. magic so that the notebook will reload external python modules\n",
"%load_ext watermark\n",
"%load_ext autoreload\n",
"%autoreload 2\n",
"%watermark\n",
"\n",
"from notebook.services.config import ConfigManager\n",
"cm = ConfigManager().update('notebook', {'limit_output': 10})"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Index(['id', 'conversation_id', 'created_at', 'date', 'time', 'timezone',\n",
" 'user_id', 'username', 'name', 'place', 'tweet', 'language', 'mentions',\n",
" 'urls', 'photos', 'replies_count', 'retweets_count', 'likes_count',\n",
" 'hashtags', 'cashtags', 'link', 'retweet', 'quote_url', 'video',\n",
" 'thumbnail', 'near', 'geo', 'source', 'user_rt_id', 'user_rt',\n",
" 'retweet_id', 'reply_to', 'retweet_date', 'translate', 'trans_src',\n",
" 'trans_dest'],\n",
" dtype='object')\n"
]
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>date</th>\n",
" <th>time</th>\n",
" <th>username</th>\n",
" <th>tweet</th>\n",
" <th>likes_count</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>2016-10-22</td>\n",
" <td>08:59:58</td>\n",
" <td>samuraicpp</td>\n",
" <td>さかな:皆でプリキュアを鑑賞中、ゆきが呆れて「いい大人が…東組が攻めてきたら終わりですね…」...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>2016-10-22</td>\n",
" <td>08:58:26</td>\n",
" <td>little_nappa</td>\n",
" <td>プリキュアを見たことはないけど次のプリキュアが キュアバース キュアブライアント キュアク...</td>\n",
" <td>1</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>2016-10-22</td>\n",
" <td>08:58:08</td>\n",
" <td>nogamisan</td>\n",
" <td>そういえば、子供に人気そうな、動物モチーフのプリキュアっていないな。東京ミュウミュウと被るか...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>2016-10-22</td>\n",
" <td>08:57:23</td>\n",
" <td>chimchikuwa</td>\n",
" <td>明日は仮面ライダーエグゼイドを観ようと思っている!! 出来ればプリキュアも観たいけど用事があ...</td>\n",
" <td>3</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>2016-10-22</td>\n",
" <td>08:56:51</td>\n",
" <td>_tsukuda_mother</td>\n",
" <td>児童ポルノを売買するオタクを訴えるためにコミケへ行きましたが、そこでは朝に放送されてた『プリ...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>...</th>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" <td>...</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1074</th>\n",
" <td>2018-12-21</td>\n",
" <td>23:33:20</td>\n",
" <td>neoorb0721</td>\n",
" <td>HUGっと!プリキュア 第44話 感想「夢と決断の旅へ!さあやの大冒険!」 https:/...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1075</th>\n",
" <td>2018-12-21</td>\n",
" <td>23:32:26</td>\n",
" <td>sll5552000</td>\n",
" <td>一応明日スタァライブのついでにプリキュアのカフェ行く予定だからとりあえずスイプリ靴はコンプし...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1076</th>\n",
" <td>2018-12-21</td>\n",
" <td>23:32:26</td>\n",
" <td>mareson_san</td>\n",
" <td>今テレビの今ドキJKが初代プリキュアの手鏡使ってたけど、よく考えたらこの子らにとっての初代プ...</td>\n",
" <td>2</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1079</th>\n",
" <td>2018-12-21</td>\n",
" <td>23:32:02</td>\n",
" <td>12megane30</td>\n",
" <td>私の心の中のプリキュア「弾けるゆずの香り!」</td>\n",
" <td>0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1080</th>\n",
" <td>2018-12-21</td>\n",
" <td>23:31:37</td>\n",
" <td>sasolina_bot</td>\n",
" <td>って思ったけど……そこら中カップルだらけじゃなぁい!! あぁん…これも全てプリキュアのせい…...</td>\n",
" <td>0</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"<p>1628273 rows × 5 columns</p>\n",
"</div>"
],
"text/plain": [
" date time username \\\n",
"0 2016-10-22 08:59:58 samuraicpp \n",
"1 2016-10-22 08:58:26 little_nappa \n",
"2 2016-10-22 08:58:08 nogamisan \n",
"3 2016-10-22 08:57:23 chimchikuwa \n",
"4 2016-10-22 08:56:51 _tsukuda_mother \n",
"... ... ... ... \n",
"1074 2018-12-21 23:33:20 neoorb0721 \n",
"1075 2018-12-21 23:32:26 sll5552000 \n",
"1076 2018-12-21 23:32:26 mareson_san \n",
"1079 2018-12-21 23:32:02 12megane30 \n",
"1080 2018-12-21 23:31:37 sasolina_bot \n",
"\n",
" tweet likes_count \n",
"0 さかな:皆でプリキュアを鑑賞中、ゆきが呆れて「いい大人が…東組が攻めてきたら終わりですね…」... 0 \n",
"1 プリキュアを見たことはないけど次のプリキュアが キュアバース キュアブライアント キュアク... 1 \n",
"2 そういえば、子供に人気そうな、動物モチーフのプリキュアっていないな。東京ミュウミュウと被るか... 0 \n",
"3 明日は仮面ライダーエグゼイドを観ようと思っている!! 出来ればプリキュアも観たいけど用事があ... 3 \n",
"4 児童ポルノを売買するオタクを訴えるためにコミケへ行きましたが、そこでは朝に放送されてた『プリ... 0 \n",
"... ... ... \n",
"1074 HUGっと!プリキュア 第44話 感想「夢と決断の旅へ!さあやの大冒険!」 https:/... 0 \n",
"1075 一応明日スタァライブのついでにプリキュアのカフェ行く予定だからとりあえずスイプリ靴はコンプし... 0 \n",
"1076 今テレビの今ドキJKが初代プリキュアの手鏡使ってたけど、よく考えたらこの子らにとっての初代プ... 2 \n",
"1079 私の心の中のプリキュア「弾けるゆずの香り!」 0 \n",
"1080 って思ったけど……そこら中カップルだらけじゃなぁい!! あぁん…これも全てプリキュアのせい…... 0 \n",
"\n",
"[1628273 rows x 5 columns]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"import glob\n",
"files = glob.glob(\"./プリキュア/*.csv\")\n",
"df = pd.concat([pd.read_csv(x, sep=\"\\t\", error_bad_lines=False) for x in files])\n",
"print(df.columns)\n",
"df = df[[\"date\", \"time\", \"username\", \"tweet\", \"likes_count\"]]\n",
"df = df[df.tweet.apply(lambda x: \"@\" not in x)]\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import math\n",
"import requests\n",
"import json"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"400\n",
"{\"error\":{\"root_cause\":[{\"type\":\"resource_already_exists_exception\",\"reason\":\"index [experiment/HAlP290HR5i_mCOvUGWkGA] already exists\",\"index_uuid\":\"HAlP290HR5i_mCOvUGWkGA\",\"index\":\"experiment\"}],\"type\":\"resource_already_exists_exception\",\"reason\":\"index [experiment/HAlP290HR5i_mCOvUGWkGA] already exists\",\"index_uuid\":\"HAlP290HR5i_mCOvUGWkGA\",\"index\":\"experiment\"},\"status\":400}\n"
]
}
],
"source": [
"# installation instructions\n",
"# https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html\n",
"\n",
"# creating an index\n",
"# https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html\n",
"settings = {\n",
" \"settings\": {\n",
" 'index': {\n",
" 'number_of_shards': 1,\n",
" 'number_of_replicas': 1,\n",
"\n",
" # configure our default similarity algorithm explicitly to use bm25,\n",
" # this allows it to use it for all the fields\n",
" 'similarity': {\n",
" 'default': {\n",
" 'type': 'BM25'\n",
" }\n",
" }\n",
" },\n",
" \"analysis\": {\n",
" \"char_filter\": {\n",
" \"normalize\": {\n",
" \"type\": \"icu_normalizer\",\n",
" \"name\": \"nfkc\",\n",
" \"mode\": \"compose\"\n",
" }\n",
" },\n",
" \"tokenizer\": {\n",
" \"ja_kuromoji_tokenizer\": {\n",
" \"mode\": \"search\",\n",
" \"type\": \"kuromoji_tokenizer\",\n",
" \"discard_compound_token\": True,\n",
" \"user_dictionary_rules\": [\n",
" \"東京スカイツリー,東京 スカイツリー,トウキョウ スカイツリー,カスタム名詞\"\n",
" ]\n",
" },\n",
" \"ja_ngram_tokenizer\": {\n",
" \"type\": \"ngram\",\n",
" \"min_gram\": 2,\n",
" \"max_gram\": 2,\n",
" \"token_chars\": [\n",
" \"letter\",\n",
" \"digit\"\n",
" ]\n",
" }\n",
" },\n",
" \"filter\": {\n",
" \"ja_index_synonym\": {\n",
" \"type\": \"synonym\",\n",
" \"lenient\": False,\n",
" \"synonyms\": [\n",
" \n",
" ]\n",
" },\n",
" \"ja_search_synonym\": {\n",
" \"type\": \"synonym_graph\",\n",
" \"lenient\": False,\n",
" \"synonyms\": [\n",
" \"米国, アメリカ\",\n",
" \"東京大学, 東大\"\n",
" ]\n",
" }\n",
" },\n",
" \"analyzer\": {\n",
" \"ja_kuromoji_index_analyzer\": {\n",
" \"type\": \"custom\",\n",
" \"char_filter\": [\n",
" \"normalize\"\n",
" ],\n",
" \"tokenizer\": \"ja_kuromoji_tokenizer\",\n",
" \"filter\": [\n",
" \"kuromoji_baseform\",\n",
" \"kuromoji_part_of_speech\",\n",
" \"ja_index_synonym\",\n",
" \"cjk_width\",\n",
" \"ja_stop\",\n",
" \"kuromoji_stemmer\",\n",
" \"lowercase\"\n",
" ]\n",
" },\n",
" \"ja_kuromoji_search_analyzer\": {\n",
" \"type\": \"custom\",\n",
" \"char_filter\": [\n",
" \"normalize\"\n",
" ],\n",
" \"tokenizer\": \"ja_kuromoji_tokenizer\",\n",
" \"filter\": [\n",
" \"kuromoji_baseform\",\n",
" \"kuromoji_part_of_speech\",\n",
" \"ja_search_synonym\",\n",
" \"cjk_width\",\n",
" \"ja_stop\",\n",
" \"kuromoji_stemmer\",\n",
" \"lowercase\"\n",
" ]\n",
" },\n",
" \"ja_ngram_index_analyzer\": {\n",
" \"type\": \"custom\",\n",
" \"char_filter\": [\n",
" \"normalize\"\n",
" ],\n",
" \"tokenizer\": \"ja_ngram_tokenizer\",\n",
" \"filter\": [\n",
" \"lowercase\"\n",
" ]\n",
" },\n",
" \"ja_ngram_search_analyzer\": {\n",
" \"type\": \"custom\",\n",
" \"char_filter\": [\n",
" \"normalize\"\n",
" ],\n",
" \"tokenizer\": \"ja_ngram_tokenizer\",\n",
" \"filter\": [\n",
" \"ja_search_synonym\",\n",
" \"lowercase\"\n",
" ]\n",
" }\n",
" }\n",
" }\n",
" },\n",
" \"mappings\": {\n",
" \"properties\": {\n",
" \"tweet\": {\n",
" \"type\": \"text\",\n",
" \"search_analyzer\": \"ja_kuromoji_search_analyzer\",\n",
" \"analyzer\": \"ja_kuromoji_index_analyzer\",\n",
" \"fields\": {\n",
" \"ngram\": {\n",
" \"type\": \"text\",\n",
" \"search_analyzer\": \"ja_ngram_search_analyzer\",\n",
" \"analyzer\": \"ja_ngram_index_analyzer\"\n",
" }\n",
" }\n",
" }\n",
" }\n",
" }\n",
"}\n",
"headers = {'Content-Type': 'application/json'}\n",
"r = requests.put('http://localhost:9200/experiment', data=json.dumps(settings), headers=headers)\n",
"print(r.status_code)\n",
"print(r.text)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'tokens': [{'token': '大好き',\n",
" 'start_offset': 0,\n",
" 'end_offset': 3,\n",
" 'type': 'word',\n",
" 'position': 0},\n",
" {'token': 'プリキュア',\n",
" 'start_offset': 4,\n",
" 'end_offset': 9,\n",
" 'type': 'word',\n",
" 'position': 1},\n",
" {'token': '5',\n",
" 'start_offset': 9,\n",
" 'end_offset': 10,\n",
" 'type': 'word',\n",
" 'position': 2},\n",
" {'token': '大好き',\n",
" 'start_offset': 10,\n",
" 'end_offset': 13,\n",
" 'type': 'word',\n",
" 'position': 3}]}"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url = 'http://localhost:9200/experiment/_analyze'\n",
"\n",
"data = {'text': \"大好き。プリキュア5大好き。\", \"tokenizer\": \"kuromoji_tokenizer\" }\n",
"response = requests.post(url, data=json.dumps(data), headers=headers)\n",
" \n",
"json.loads(response.text)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"<ipython-input-7-c9a794ded244>:3: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0\n",
"Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`\n",
" for i in tqdm_notebook(range(len(df[:30]))):\n"
]
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7a570af47edc4f9ea718be948394870f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(FloatProgress(value=0.0, max=30.0), HTML(value='')))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
},
{
"data": {
"text/plain": [
"{'_index': 'experiment',\n",
" '_type': '_doc',\n",
" '_id': 'lbpBr3cBe-XfFcbgJ1pi',\n",
" '_version': 1,\n",
" 'result': 'created',\n",
" '_shards': {'total': 2, 'successful': 1, 'failed': 0},\n",
" '_seq_no': 422276,\n",
" '_primary_term': 1}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"url = 'http://localhost:9200/experiment/_doc'\n",
"from tqdm import tqdm_notebook\n",
"for i in tqdm_notebook(range(len(df[:30]))):\n",
" # we insert the document into the 'title' field\n",
" r = df.iloc[i]\n",
"\n",
" data = {'tweet': r.tweet, \"username\": r.username }\n",
" response = requests.post(url, data=json.dumps(data), headers=headers)\n",
" \n",
"json.loads(response.text)\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"10000\n",
"20000\n",
"30000\n",
"40000\n",
"50000\n",
"60000\n",
"70000\n",
"80000\n",
"90000\n",
"100000\n",
"110000\n",
"120000\n",
"130000\n",
"140000\n",
"150000\n",
"160000\n",
"170000\n",
"180000\n",
"190000\n",
"200000\n",
"210000\n",
"220000\n",
"230000\n",
"240000\n",
"250000\n",
"260000\n",
"270000\n",
"280000\n",
"290000\n",
"300000\n",
"310000\n",
"320000\n",
"330000\n",
"340000\n",
"350000\n",
"360000\n",
"370000\n",
"380000\n",
"390000\n",
"400000\n",
"410000\n",
"420000\n",
"430000\n",
"440000\n",
"450000\n",
"460000\n",
"470000\n",
"480000\n",
"490000\n",
"500000\n",
"510000\n",
"520000\n",
"530000\n",
"540000\n",
"550000\n",
"560000\n",
"570000\n",
"580000\n",
"590000\n",
"600000\n",
"610000\n",
"620000\n",
"630000\n",
"640000\n",
"650000\n",
"660000\n",
"670000\n",
"680000\n",
"690000\n",
"700000\n",
"710000\n",
"720000\n",
"730000\n",
"740000\n",
"750000\n",
"760000\n",
"770000\n",
"780000\n",
"790000\n",
"800000\n",
"810000\n",
"820000\n",
"830000\n",
"840000\n",
"850000\n",
"860000\n",
"870000\n",
"880000\n",
"890000\n",
"900000\n",
"910000\n",
"920000\n",
"930000\n",
"940000\n",
"950000\n",
"960000\n",
"970000\n",
"980000\n",
"990000\n",
"1000000\n",
"1010000\n",
"1020000\n",
"1030000\n",
"1040000\n",
"1050000\n",
"1060000\n",
"1070000\n",
"1080000\n",
"1090000\n",
"1100000\n",
"1110000\n",
"1120000\n",
"1130000\n",
"1140000\n",
"1150000\n",
"1160000\n",
"1170000\n",
"1180000\n",
"1190000\n",
"1200000\n",
"1210000\n",
"1220000\n",
"1230000\n",
"1240000\n",
"1250000\n",
"1260000\n",
"1270000\n",
"1280000\n",
"1290000\n",
"1300000\n",
"1310000\n",
"1320000\n",
"1330000\n",
"1340000\n",
"1350000\n",
"1360000\n",
"1370000\n",
"1380000\n",
"1390000\n",
"1400000\n",
"1410000\n",
"1420000\n",
"1430000\n",
"1440000\n",
"1450000\n",
"1460000\n",
"1470000\n",
"1480000\n",
"1490000\n",
"1500000\n",
"1510000\n",
"1520000\n",
"1530000\n",
"1540000\n",
"1550000\n",
"1560000\n",
"1570000\n",
"1580000\n",
"1590000\n",
"1600000\n",
"1610000\n",
"1620000\n",
"finish\n"
]
}
],
"source": [
"\n",
"for k in range(0, len(df), 10000): \n",
" print(k)\n",
" bulk = \"\"\n",
" for i in range(k, k+10000):\n",
" try:\n",
" r = df.iloc[i]\n",
" except:\n",
" break\n",
"\n",
" index = json.dumps({\"index\": {\"_id\": i}})\n",
" data = {'tweet': r.tweet, \"username\": r.username }\n",
" #print(json.dumps(data, ensure_ascii=False))\n",
" bulk += index + '\\n' + json.dumps(data, ensure_ascii=True) + '\\n'\n",
"\n",
" url = 'http://localhost:9200/experiment/_bulk'\n",
"\n",
" response = requests.post(url, data=bulk, headers={'Content-Type': 'application/x-ndjson'})\n",
" response.text\n",
"#response.text\n",
"print(\"finish\")"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"\n",
"def search(query, headers, params=None):\n",
" url = 'http://localhost:9200/experiment/_doc/_search'\n",
" response = requests.get(url, data=json.dumps(query), headers=headers, params=params)\n",
" \n",
" # the response contains other information, such as time it took to\n",
" # give the response back, here we are only interested in the matched\n",
" # results, which are stored under 'hits'\n",
" #print(response.text)\n",
" search_hits = json.loads(response.text)['hits']['hits']\n",
"\n",
" print('Num\\tRelevance Score\\tTitle')\n",
" for idx, hit in enumerate(search_hits):\n",
" print(idx + 1, hit['_score'], hit['_source']['username'], hit['_source']['tweet'])"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Num\tRelevance Score\tTitle\n",
"1 12.090488 kazekosan1008 #は行の前に大好きなを付けると感動的 大好きな話 大好きなピヨさん 大好きなプリキュア 大好きな別府 大好きな本当に 一つ大好きじゃないなぁ\n",
"2 12.007816 yukichibanboshi Sweet Bell本当フリカワイイ~!大好き!大好き!大好き! プリキュアみたい………\n",
"3 11.994567 ricoma_1156 大好き。プリキュア5大好き。\n",
"4 11.953572 kukuaya0604 プリキュア大好き女子が好き 身内大好き\n",
"5 11.866549 yonesakunext #ぱぴぷぺぽの後に大好きを付けると本性がバレる パンツ大好き ピンク大好き プリキュア大好き ペット大好き ポンポン大好き おまわりさん、こいつです。\n",
"6 11.830531 tamakierika プリキュアも大好きだけどキューティーハニーも大大大好き!!\n",
"7 11.830531 tamakierika プリキュアも大好きだけどキューティーハニーも大大大好き!!\n",
"8 11.830531 tamakierika プリキュアも大好きだけどキューティーハニーも大大大好き!!\n",
"9 11.830531 tamakierika プリキュアも大好きだけどキューティーハニーも大大大好き!!\n",
"10 11.830531 tamakierika プリキュアも大好きだけどキューティーハニーも大大大好き!!\n"
]
}
],
"source": [
"# match query\n",
"# https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query.html\n",
"query = {\n",
" 'query': {\n",
" 'match': {\n",
" # search against the 'title' field\n",
" 'tweet': ' プリキュア'\n",
" }\n",
" }\n",
"}\n",
"\n",
"query = {\n",
" 'query': {\n",
" 'multi_match': {\n",
" \"fields\": [\"tweet\"],\n",
" \"query\": \"大好き\"\n",
" }\n",
" }\n",
"}\n",
"\n",
"search(query, headers={'Content-Type': 'application/json'}, params={\"search_type\":\"dfs_query_then_fetch\"})"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1 {'_index': 'experiment', '_type': '_doc', '_id': 'eLpBr3cBe-XfFcbgJlo7', '_score': 1.0, '_source': {'tweet': 'さかな:皆でプリキュアを鑑賞中、ゆきが呆れて「いい大人が…東組が攻めてきたら終わりですね…」と言うと黒は「ふざけるな!」と一喝。おぉ、いいぞ!俺が守ると言え!と心の中でエールを送ったが「プリキュアが守ってくれるに決まってるだろ!!」西組終わってた。', 'username': 'samuraicpp'}}\n",
"2 {'_index': 'experiment', '_type': '_doc', '_id': 'ebpBr3cBe-XfFcbgJlpE', '_score': 1.0, '_source': {'tweet': 'プリキュアを見たことはないけど次のプリキュアが キュアバース キュアブライアント キュアクロマティ キュアデストラーデ の「プリキュアスケットガイコクジン」なら見る 追加戦士はキュアイースラーで', 'username': 'little_nappa'}}\n",
"3 {'_index': 'experiment', '_type': '_doc', '_id': 'erpBr3cBe-XfFcbgJlpO', '_score': 1.0, '_source': {'tweet': 'そういえば、子供に人気そうな、動物モチーフのプリキュアっていないな。東京ミュウミュウと被るからかな。', 'username': 'nogamisan'}}\n",
"4 {'_index': 'experiment', '_type': '_doc', '_id': 'e7pBr3cBe-XfFcbgJlpY', '_score': 1.0, '_source': {'tweet': '明日は仮面ライダーエグゼイドを観ようと思っている!! 出来ればプリキュアも観たいけど用事があって観れなさそう(・ω・`(・ω・`(・ω・`)', 'username': 'chimchikuwa'}}\n",
"5 {'_index': 'experiment', '_type': '_doc', '_id': 'fLpBr3cBe-XfFcbgJlph', '_score': 1.0, '_source': {'tweet': '児童ポルノを売買するオタクを訴えるためにコミケへ行きましたが、そこでは朝に放送されてた『プリキュア』の裸の絵がありました。私はテレ朝にこのような不健全な番組を止めるよう訴えましたが、同人誌は関係ないと詭弁を言うだけで反省すらしません。アニメは作る側もモラルが無く呆れてしまいます。', 'username': '_tsukuda_mother'}}\n",
"6 {'_index': 'experiment', '_type': '_doc', '_id': 'fbpBr3cBe-XfFcbgJlpr', '_score': 1.0, '_source': {'tweet': '大泉のプリキュア最速上映今回もあると思っといていいんですよね…', 'username': 'hamigaki'}}\n",
"7 {'_index': 'experiment', '_type': '_doc', '_id': 'frpBr3cBe-XfFcbgJlp0', '_score': 1.0, '_source': {'tweet': 'プリキュア試写会ワクワクもんだぁ https://t.co/w14utCyK8h', 'username': 'munouyakutatazu'}}\n",
"8 {'_index': 'experiment', '_type': '_doc', '_id': 'f7pBr3cBe-XfFcbgJlp-', '_score': 1.0, '_source': {'tweet': '最近、放送延期するアニメが増えたけど、プリキュアありがとう。 - プリキュアの数字ブログ https://t.co/8U3IDboYPe', 'username': 'deltaman00'}}\n",
"9 {'_index': 'experiment', '_type': '_doc', '_id': 'gLpBr3cBe-XfFcbgJlqH', '_score': 1.0, '_source': {'tweet': 'あれ、来年のプリキュアの商標登録まだ来ないのか。今年遅い?来月かな。', 'username': 'nogamisan'}}\n",
"10 {'_index': 'experiment', '_type': '_doc', '_id': 'gbpBr3cBe-XfFcbgJlqR', '_score': 1.0, '_source': {'tweet': '俺はプリキュア', 'username': 'tokitoki3p'}}\n",
"11 {'_index': 'experiment', '_type': '_doc', '_id': 'grpBr3cBe-XfFcbgJlqd', '_score': 1.0, '_source': {'tweet': 'Perfumeとプリキュアでテンアゲ⤴⤴⤴⤴⤴⤴すっからな', 'username': 'onikumeet'}}\n",
"12 {'_index': 'experiment', '_type': '_doc', '_id': 'g7pBr3cBe-XfFcbgJlqn', '_score': 1.0, '_source': {'tweet': '『てめえ何しやがる!』「ふっ、プリキュアを倒すのはこの僕だ!」『まさか、』「記憶が……。そう…よかった……。」「!な、なんで喜んでんだよ……変な奴。」「だって、嬉しいんだもん。きっとこれが私の、素直な気持ちなんだと思う。」', 'username': 'irarikka_bot'}}\n",
"13 {'_index': 'experiment', '_type': '_doc', '_id': 'hLpBr3cBe-XfFcbgJlqx', '_score': 1.0, '_source': {'tweet': 'プリキュア解散!ぶっちゃけ早すぎ!?', 'username': 'futarihaprecure'}}\n",
"14 {'_index': 'experiment', '_type': '_doc', '_id': 'hbpBr3cBe-XfFcbgJlq7', '_score': 1.0, '_source': {'tweet': 'プリキュアの制服はいろいろ魅力的だよな', 'username': 't_zetukimi60'}}\n",
"15 {'_index': 'experiment', '_type': '_doc', '_id': 'hrpBr3cBe-XfFcbgJlrF', '_score': 1.0, '_source': {'tweet': '【定期】戦国BASARA/銀魂/テニプリ/ジョジョ/ハイキュー/アイナナ/とうらぶ/ポケスペ/プリキュア/薄桜鬼/スラダン/弱ペダ/テラフォ/おそ松さん#RTしてくれた人と繋がりたい(※ツイフィ一読お願いします)', 'username': 'klamlk_teaa1374'}}\n",
"16 {'_index': 'experiment', '_type': '_doc', '_id': 'h7pBr3cBe-XfFcbgJlrP', '_score': 1.0, '_source': {'tweet': 'おそらく、仲間の妖精やプリキュアのところに向かったのであろう。お前たちは第三の妖精を生け捕りにしてくるのだ。', 'username': 'dr_sabaku_bot'}}\n",
"17 {'_index': 'experiment', '_type': '_doc', '_id': 'iLpBr3cBe-XfFcbgJlrZ', '_score': 1.0, '_source': {'tweet': '2009年放送のアニメ『フレッシュプリキュア!』で、プリキュアが戦う悪の組織ラビリンスが生み出した怪物は?→ナケワメーケ', 'username': 'ani_narabe_bot'}}\n",
"18 {'_index': 'experiment', '_type': '_doc', '_id': 'ibpBr3cBe-XfFcbgJlrj', '_score': 1.0, '_source': {'tweet': 'イシス「皆でプリキュアを鑑賞中、ロキが呆れて「いい年して全く…強敵が攻めてきたらここは終わりですね」と言うとアンタレスは「ふざけるな!」と一喝。おっ!ここは私達が守ると言って!と心の中でエールを送ったけど「プリキュアが守ってくれるに決まってるだろ!!」このチーム終わってた。」', 'username': 'paz_homo_rez'}}\n",
"19 {'_index': 'experiment', '_type': '_doc', '_id': 'irpBr3cBe-XfFcbgJlrt', '_score': 1.0, '_source': {'tweet': 'はっはっはー!これでプリキュアを捕まえたニャー!', 'username': 'hammy_bot'}}\n",
"20 {'_index': 'experiment', '_type': '_doc', '_id': 'i7pBr3cBe-XfFcbgJlr4', '_score': 1.0, '_source': {'tweet': 'さっき、電車でぐずる子供に「静かにしなさい!そんなんじゃ立派なプリキュアになれないよ!」って 叱ったお母さんと、一瞬でキリッと静かになった女の子が可愛かった。 あと隣に座ってた大学生のお兄さんも少しキリッとなった。', 'username': 'bakusokutw'}}\n",
"21 {'_index': 'experiment', '_type': '_doc', '_id': 'jLpBr3cBe-XfFcbgJ1oF', '_score': 1.0, '_source': {'tweet': '久しぶりの喫茶マウンテン 魔法つかいプリキュアの痛車が気になりました(^ω^) https://t.co/zkd2BF8lS7', 'username': 'syou526'}}\n",
"22 {'_index': 'experiment', '_type': '_doc', '_id': 'jbpBr3cBe-XfFcbgJ1oQ', '_score': 1.0, '_source': {'tweet': '[イコやんたちモフルン達と記念写真]の巻 もーじき上映されるプリキュア映画は、このぬいぐるみ🐻がプリキュアに変身するらしいで! ホンマかいな!ほなワイらも変身できる可能性があるねんな! 名前は…… キュアイコカ! キュアスマイコ! よっしゃー!これで決まりやな❗💮 https://t.co/StaU4zSFSE', 'username': 'setunaicoca'}}\n",
"23 {'_index': 'experiment', '_type': '_doc', '_id': 'jrpBr3cBe-XfFcbgJ1oa', '_score': 1.0, '_source': {'tweet': 'プリキュア試写会に行ってくるぞぃ https://t.co/We0Sn7BhhR', 'username': 'sakubo_godfate'}}\n",
"24 {'_index': 'experiment', '_type': '_doc', '_id': 'j7pBr3cBe-XfFcbgJ1ok', '_score': 1.0, '_source': {'tweet': 'ラテアート【キュアハート(相田マナ)】ドキドキ!プリキュア https://t.co/2V8vO5gf1z', 'username': 'latteart0'}}\n",
"25 {'_index': 'experiment', '_type': '_doc', '_id': 'kLpBr3cBe-XfFcbgJ1ou', '_score': 1.0, '_source': {'tweet': '等身大キュアハート! プリキュア10周年!ドキドキ!プリキュア| Cure Heart Dokidoki! PreCure 10th Anniversary https://t.co/UEhcwf1ST5', 'username': 'kidsjapanch'}}\n",
"26 {'_index': 'experiment', '_type': '_doc', '_id': 'kbpBr3cBe-XfFcbgJ1o5', '_score': 1.0, '_source': {'tweet': '【朝の光景】 うた「二度寝せずに起きたら私は最高にクールなヒーローだ…」 まゆげ「毛たるもの起きないと…」 栢杜「就業規則第二条三項…」 吉岡「今起きることは罪だ…よし起きよう」 ネーギラス「朝飯…」 あんこ「プリキュア…」', 'username': 'kichi_copy'}}\n",
"27 {'_index': 'experiment', '_type': '_doc', '_id': 'krpBr3cBe-XfFcbgJ1pD', '_score': 1.0, '_source': {'tweet': '三人目ぇっ!!? 黄色のプリキュアっ!? 目立ちすぎよぉっ!! やっちゃってぇっ!!', 'username': 'sasolina_bot'}}\n",
"28 {'_index': 'experiment', '_type': '_doc', '_id': 'k7pBr3cBe-XfFcbgJ1pN', '_score': 1.0, '_source': {'tweet': '武田信玄「プリキュアなんぞせいぜい月に4回くらいしか見ないのお」', 'username': '1059t_cpp'}}\n",
"29 {'_index': 'experiment', '_type': '_doc', '_id': 'lLpBr3cBe-XfFcbgJ1pY', '_score': 1.0, '_source': {'tweet': 'ドフラミンゴ:ベビー5がプリキュアごっこをやっていたらヴェルゴも参加しようとしたから「男の人はプリキュアになれないのよ!」とベビー5が言うと、「俺はプリキュアになれないのか…!?なぜ…!」と既に役に入っていた。たくましい。', 'username': 'df__bot'}}\n",
"30 {'_index': 'experiment', '_type': '_doc', '_id': 'lbpBr3cBe-XfFcbgJ1pi', '_score': 1.0, '_source': {'tweet': '知性のプリキュアは伊達じゃないわよ!', 'username': 'karen_minaduki'}}\n",
"31 {'_index': 'experiment', '_type': '_doc', '_id': '0', '_score': 1.0, '_source': {'tweet': 'さかな:皆でプリキュアを鑑賞中、ゆきが呆れて「いい大人が…東組が攻めてきたら終わりですね…」と言うと黒は「ふざけるな!」と一喝。おぉ、いいぞ!俺が守ると言え!と心の中でエールを送ったが「プリキュアが守ってくれるに決まってるだろ!!」西組終わってた。', 'username': 'samuraicpp'}}\n",
"32 {'_index': 'experiment', '_type': '_doc', '_id': '1', '_score': 1.0, '_source': {'tweet': 'プリキュアを見たことはないけど次のプリキュアが キュアバース キュアブライアント キュアクロマティ キュアデストラーデ の「プリキュアスケットガイコクジン」なら見る 追加戦士はキュアイースラーで', 'username': 'little_nappa'}}\n",
"33 {'_index': 'experiment', '_type': '_doc', '_id': '2', '_score': 1.0, '_source': {'tweet': 'そういえば、子供に人気そうな、動物モチーフのプリキュアっていないな。東京ミュウミュウと被るからかな。', 'username': 'nogamisan'}}\n",
"34 {'_index': 'experiment', '_type': '_doc', '_id': '3', '_score': 1.0, '_source': {'tweet': '明日は仮面ライダーエグゼイドを観ようと思っている!! 出来ればプリキュアも観たいけど用事があって観れなさそう(・ω・`(・ω・`(・ω・`)', 'username': 'chimchikuwa'}}\n",
"35 {'_index': 'experiment', '_type': '_doc', '_id': '4', '_score': 1.0, '_source': {'tweet': '児童ポルノを売買するオタクを訴えるためにコミケへ行きましたが、そこでは朝に放送されてた『プリキュア』の裸の絵がありました。私はテレ朝にこのような不健全な番組を止めるよう訴えましたが、同人誌は関係ないと詭弁を言うだけで反省すらしません。アニメは作る側もモラルが無く呆れてしまいます。', 'username': '_tsukuda_mother'}}\n",
"36 {'_index': 'experiment', '_type': '_doc', '_id': '5', '_score': 1.0, '_source': {'tweet': '大泉のプリキュア最速上映今回もあると思っといていいんですよね…', 'username': 'hamigaki'}}\n",
"37 {'_index': 'experiment', '_type': '_doc', '_id': '6', '_score': 1.0, '_source': {'tweet': 'プリキュア試写会ワクワクもんだぁ https://t.co/w14utCyK8h', 'username': 'munouyakutatazu'}}\n",
"38 {'_index': 'experiment', '_type': '_doc', '_id': '7', '_score': 1.0, '_source': {'tweet': '最近、放送延期するアニメが増えたけど、プリキュアありがとう。 - プリキュアの数字ブログ https://t.co/8U3IDboYPe', 'username': 'deltaman00'}}\n",
"39 {'_index': 'experiment', '_type': '_doc', '_id': '8', '_score': 1.0, '_source': {'tweet': 'あれ、来年のプリキュアの商標登録まだ来ないのか。今年遅い?来月かな。', 'username': 'nogamisan'}}\n",
"40 {'_index': 'experiment', '_type': '_doc', '_id': '9', '_score': 1.0, '_source': {'tweet': '俺はプリキュア', 'username': 'tokitoki3p'}}\n",
"41 {'_index': 'experiment', '_type': '_doc', '_id': '10', '_score': 1.0, '_source': {'tweet': 'Perfumeとプリキュアでテンアゲ⤴⤴⤴⤴⤴⤴すっからな', 'username': 'onikumeet'}}\n",
"42 {'_index': 'experiment', '_type': '_doc', '_id': '11', '_score': 1.0, '_source': {'tweet': '『てめえ何しやがる!』「ふっ、プリキュアを倒すのはこの僕だ!」『まさか、』「記憶が……。そう…よかった……。」「!な、なんで喜んでんだよ……変な奴。」「だって、嬉しいんだもん。きっとこれが私の、素直な気持ちなんだと思う。」', 'username': 'irarikka_bot'}}\n",
"43 {'_index': 'experiment', '_type': '_doc', '_id': '12', '_score': 1.0, '_source': {'tweet': 'プリキュア解散!ぶっちゃけ早すぎ!?', 'username': 'futarihaprecure'}}\n",
"44 {'_index': 'experiment', '_type': '_doc', '_id': '13', '_score': 1.0, '_source': {'tweet': 'プリキュアの制服はいろいろ魅力的だよな', 'username': 't_zetukimi60'}}\n",
"45 {'_index': 'experiment', '_type': '_doc', '_id': '14', '_score': 1.0, '_source': {'tweet': '【定期】戦国BASARA/銀魂/テニプリ/ジョジョ/ハイキュー/アイナナ/とうらぶ/ポケスペ/プリキュア/薄桜鬼/スラダン/弱ペダ/テラフォ/おそ松さん#RTしてくれた人と繋がりたい(※ツイフィ一読お願いします)', 'username': 'klamlk_teaa1374'}}\n",
"46 {'_index': 'experiment', '_type': '_doc', '_id': '15', '_score': 1.0, '_source': {'tweet': 'おそらく、仲間の妖精やプリキュアのところに向かったのであろう。お前たちは第三の妖精を生け捕りにしてくるのだ。', 'username': 'dr_sabaku_bot'}}\n",
"47 {'_index': 'experiment', '_type': '_doc', '_id': '16', '_score': 1.0, '_source': {'tweet': '2009年放送のアニメ『フレッシュプリキュア!』で、プリキュアが戦う悪の組織ラビリンスが生み出した怪物は?→ナケワメーケ', 'username': 'ani_narabe_bot'}}\n",
"48 {'_index': 'experiment', '_type': '_doc', '_id': '17', '_score': 1.0, '_source': {'tweet': 'イシス「皆でプリキュアを鑑賞中、ロキが呆れて「いい年して全く…強敵が攻めてきたらここは終わりですね」と言うとアンタレスは「ふざけるな!」と一喝。おっ!ここは私達が守ると言って!と心の中でエールを送ったけど「プリキュアが守ってくれるに決まってるだろ!!」このチーム終わってた。」', 'username': 'paz_homo_rez'}}\n",
"49 {'_index': 'experiment', '_type': '_doc', '_id': '18', '_score': 1.0, '_source': {'tweet': 'はっはっはー!これでプリキュアを捕まえたニャー!', 'username': 'hammy_bot'}}\n",
"50 {'_index': 'experiment', '_type': '_doc', '_id': '19', '_score': 1.0, '_source': {'tweet': 'さっき、電車でぐずる子供に「静かにしなさい!そんなんじゃ立派なプリキュアになれないよ!」って 叱ったお母さんと、一瞬でキリッと静かになった女の子が可愛かった。 あと隣に座ってた大学生のお兄さんも少しキリッとなった。', 'username': 'bakusokutw'}}\n",
"51 {'_index': 'experiment', '_type': '_doc', '_id': '20', '_score': 1.0, '_source': {'tweet': '久しぶりの喫茶マウンテン 魔法つかいプリキュアの痛車が気になりました(^ω^) https://t.co/zkd2BF8lS7', 'username': 'syou526'}}\n",
"52 {'_index': 'experiment', '_type': '_doc', '_id': '21', '_score': 1.0, '_source': {'tweet': '[イコやんたちモフルン達と記念写真]の巻 もーじき上映されるプリキュア映画は、このぬいぐるみ🐻がプリキュアに変身するらしいで! ホンマかいな!ほなワイらも変身できる可能性があるねんな! 名前は…… キュアイコカ! キュアスマイコ! よっしゃー!これで決まりやな❗💮 https://t.co/StaU4zSFSE', 'username': 'setunaicoca'}}\n",
"53 {'_index': 'experiment', '_type': '_doc', '_id': '22', '_score': 1.0, '_source': {'tweet': 'プリキュア試写会に行ってくるぞぃ https://t.co/We0Sn7BhhR', 'username': 'sakubo_godfate'}}\n",
"54 {'_index': 'experiment', '_type': '_doc', '_id': '23', '_score': 1.0, '_source': {'tweet': 'ラテアート【キュアハート(相田マナ)】ドキドキ!プリキュア https://t.co/2V8vO5gf1z', 'username': 'latteart0'}}\n",
"55 {'_index': 'experiment', '_type': '_doc', '_id': '24', '_score': 1.0, '_source': {'tweet': '等身大キュアハート! プリキュア10周年!ドキドキ!プリキュア| Cure Heart Dokidoki! PreCure 10th Anniversary https://t.co/UEhcwf1ST5', 'username': 'kidsjapanch'}}\n",
"56 {'_index': 'experiment', '_type': '_doc', '_id': '25', '_score': 1.0, '_source': {'tweet': '【朝の光景】 うた「二度寝せずに起きたら私は最高にクールなヒーローだ…」 まゆげ「毛たるもの起きないと…」 栢杜「就業規則第二条三項…」 吉岡「今起きることは罪だ…よし起きよう」 ネーギラス「朝飯…」 あんこ「プリキュア…」', 'username': 'kichi_copy'}}\n",
"57 {'_index': 'experiment', '_type': '_doc', '_id': '26', '_score': 1.0, '_source': {'tweet': '三人目ぇっ!!? 黄色のプリキュアっ!? 目立ちすぎよぉっ!! やっちゃってぇっ!!', 'username': 'sasolina_bot'}}\n",
"58 {'_index': 'experiment', '_type': '_doc', '_id': '27', '_score': 1.0, '_source': {'tweet': '武田信玄「プリキュアなんぞせいぜい月に4回くらいしか見ないのお」', 'username': '1059t_cpp'}}\n",
"59 {'_index': 'experiment', '_type': '_doc', '_id': '28', '_score': 1.0, '_source': {'tweet': 'ドフラミンゴ:ベビー5がプリキュアごっこをやっていたらヴェルゴも参加しようとしたから「男の人はプリキュアになれないのよ!」とベビー5が言うと、「俺はプリキュアになれないのか…!?なぜ…!」と既に役に入っていた。たくましい。', 'username': 'df__bot'}}\n",
"60 {'_index': 'experiment', '_type': '_doc', '_id': '29', '_score': 1.0, '_source': {'tweet': '知性のプリキュアは伊達じゃないわよ!', 'username': 'karen_minaduki'}}\n",
"61 {'_index': 'experiment', '_type': '_doc', '_id': '30', '_score': 1.0, '_source': {'tweet': '世界はまるで、メリーゴーランドッ♪愛は変わるよ、3,2,1♪ きらめいてエブリディ♪ ドキド〜キ、プリキュア〜♪', 'username': 'rivasan_bot'}}\n",
"62 {'_index': 'experiment', '_type': '_doc', '_id': '31', '_score': 1.0, '_source': {'tweet': 'T・ジョイSEIBU大泉の映画魔法つかいプリキュア!の試写会に当選した方に誘われたので、これから見てきます #precure https://t.co/oKZkuMweNN', 'username': 'setsuna_love'}}\n",
"63 {'_index': 'experiment', '_type': '_doc', '_id': '32', '_score': 1.0, '_source': {'tweet': 'GION:雪だー!きれいーー!!\\u3000\\u3000重盛:お主ら雪ではしゃぐとか子どもか…フッ……\\u3000\\u3000清盛:雪合戦しよう宗盛、敦盛ーーーーwwwwwwwwwフォアッwwwwwww仕事?wwwwww知らんwwwwwwwwwwww\\u3000\\u3000知盛・重衡:プリキュア!!ビューティブリザーード!!!!', 'username': 'kymrti_copybot'}}\n",
"64 {'_index': 'experiment', '_type': '_doc', '_id': '33', '_score': 1.0, '_source': {'tweet': 'プリキュア手帳なう♪ 今日は何を書こうかな~。', 'username': 'misumi_nagisa_'}}\n",
"65 {'_index': 'experiment', '_type': '_doc', '_id': '34', '_score': 1.0, '_source': {'tweet': '魔法つかいプリキュア!が思うならそうなんだろう。お前の中ではな。 『映画魔法つかいプリキュア!』、同時上映の短編より先行映像を公開 https://t.co/QmiT1usKcd #ハッカドール', 'username': 'nanairoyagi'}}\n",
"66 {'_index': 'experiment', '_type': '_doc', '_id': '35', '_score': 1.0, '_source': {'tweet': 'プリキュア!ラブリンク!', 'username': 'yuinouta1'}}\n",
"67 {'_index': 'experiment', '_type': '_doc', '_id': '36', '_score': 1.0, '_source': {'tweet': 'プリキュアは泣きアニメ最終回が', 'username': 'misakaguro'}}\n",
"68 {'_index': 'experiment', '_type': '_doc', '_id': '37', '_score': 1.0, '_source': {'tweet': 'ときめきなさい!エースショット!!! ##プリキュア\\u3000#precure', 'username': 'cure_ace_aguri'}}\n",
"69 {'_index': 'experiment', '_type': '_doc', '_id': '38', '_score': 1.0, '_source': {'tweet': 'ツンツンしてた子、何なら対立側にいた子と何かのきっかけで和解し新しいメンバーに加入するのもすごくプリキュアみある…', 'username': 'mabo_jikkyou'}}\n",
"70 {'_index': 'experiment', '_type': '_doc', '_id': '39', '_score': 1.0, '_source': {'tweet': '阿近「プリキュア変身セット最後の1個買ったら幼女が後ろで泣き出した。」', 'username': 'gikyoku_copy'}}\n",
"71 {'_index': 'experiment', '_type': '_doc', '_id': '40', '_score': 1.0, '_source': {'tweet': '唐澤貴洋「ドキドキだけがプリキュア!他は駄作ナリよ〜」\\u3000#ドキドキプリキュア #プリキュア #precure #dokidoki_precure', 'username': 'tmr2_78_3'}}\n",
"72 {'_index': 'experiment', '_type': '_doc', '_id': '41', '_score': 1.0, '_source': {'tweet': 'プリキュアのなんか変なぬいぐるみみたいなやつはこいつね https://t.co/KbmAQ5TDRK', 'username': 'sakine_bot'}}\n",
"73 {'_index': 'experiment', '_type': '_doc', '_id': '42', '_score': 1.0, '_source': {'tweet': '映画『魔法つかいプリキュア!』 フルCGのモッフモフなスペシャル先行映像が期間限定公開! : ぷりそく! https://t.co/Ml7lNvOQ1j', 'username': 'sasakatu85'}}\n",
"74 {'_index': 'experiment', '_type': '_doc', '_id': '43', '_score': 1.0, '_source': {'tweet': '【画像あり】プリキュアを貧乳に描く奴wwwwwwwwwwww https://t.co/0X8LJ8JvN7 https://t.co/dxkk8XCn1n', 'username': 'usohonto860'}}\n",
"75 {'_index': 'experiment', '_type': '_doc', '_id': '44', '_score': 1.0, '_source': {'tweet': '【画像あり】プリキュアを貧乳に描く奴wwwwwwwwwwww https://t.co/eWyHcrxKFK https://t.co/Bhu1OQXvFj', 'username': 'che860'}}\n",
"76 {'_index': 'experiment', '_type': '_doc', '_id': '45', '_score': 1.0, '_source': {'tweet': 'ダニエル:仮に私が伝説のプリキュアだとするだろ? ユリア:通報した', 'username': 'manbo_fuha'}}\n",
"77 {'_index': 'experiment', '_type': '_doc', '_id': '46', '_score': 1.0, '_source': {'tweet': 'テレビで「男の子に大人気のイナズマイレブンと、女の子に大人気のプリキュア」って説明してるのを聞いて、「プッ。やだこの番組、男女逆じゃん!」って素でツッコんだ。 違う。テレビが言ってるのは大きなお友達の話じゃない。', 'username': 's911company'}}\n",
"78 {'_index': 'experiment', '_type': '_doc', '_id': '47', '_score': 1.0, '_source': {'tweet': '佳子:昔お母さんと一緒にプリキュアごっこをやっていたら、遊びに来ていた叔父様も参加しようとしたから「男の人はプリキュアになれないよ!」と言うと、「私はプリキュアになれないの…!?なぜ…!」と既に役に入っていた。たくましい。', 'username': 'copybot_lj'}}\n",
"79 {'_index': 'experiment', '_type': '_doc', '_id': '48', '_score': 1.0, '_source': {'tweet': '「おはよう、メップル、ポルン。今日から学校なんだ」(美墨なぎさ)【ふたりはプリキュアMax Heart】第1話', 'username': 'precure_meigen'}}\n",
"80 {'_index': 'experiment', '_type': '_doc', '_id': '49', '_score': 1.0, '_source': {'tweet': 'そ~いえば… 昨日ゆいちゃんにクリスマスプレゼント何がいいか聞いてみた! でもまだ決まってないらしい… 唯一言ったのがプリキュアのケーキ… 去年11月に予約しに行ったら予約できなかったので今年は今日ゲオの帰りに予約してくる~ プレゼントはまたゆいちゃんとトイザらスデートだな(笑)', 'username': 'yuichanbaba66'}}\n",
"81 {'_index': 'experiment', '_type': '_doc', '_id': '50', '_score': 1.0, '_source': {'tweet': '毎日 畑にリンゴ🍎のお手伝いに行って アイカツできないし、録画も 溜まりまくり(# ゜Д゜)💢 DCDプリキュアも気になるし・・・・秋フェスもやりたいし・・・・', 'username': 'mioko_non'}}\n",
"82 {'_index': 'experiment', '_type': '_doc', '_id': '51', '_score': 1.0, '_source': {'tweet': '友達と映画館行って「やっぱプリキュアみよーぜー」と言ってみる', 'username': 'precure_aruaru'}}\n",
"83 {'_index': 'experiment', '_type': '_doc', '_id': '52', '_score': 1.0, '_source': {'tweet': '【画像あり】プリキュアを貧乳に描く奴wwwwwwwwwwww https://t.co/kVnfPTEULU https://t.co/qILTI3BAa0', 'username': '860860satoru'}}\n",
"84 {'_index': 'experiment', '_type': '_doc', '_id': '53', '_score': 1.0, '_source': {'tweet': 'プリキュア見ようとTV点けたら越前殿が出てた', 'username': 'keenedge1223'}}\n",
"85 {'_index': 'experiment', '_type': '_doc', '_id': '54', '_score': 1.0, '_source': {'tweet': '【画像あり】プリキュアを貧乳に描く奴wwwwwwwwwwww https://t.co/XeceS60Dn2 https://t.co/lYqyRo15fI', 'username': 'shihocchi860'}}\n",
"86 {'_index': 'experiment', '_type': '_doc', '_id': '55', '_score': 1.0, '_source': {'tweet': '【画像あり】プリキュアを貧乳に描く奴wwwwwwwwwwww https://t.co/j7lHlWbHwJ https://t.co/KtIg68EyFC', 'username': 'kosuke860'}}\n",
"87 {'_index': 'experiment', '_type': '_doc', '_id': '56', '_score': 1.0, '_source': {'tweet': 'プリキュア観れない(絶望)', 'username': 'yksbktat_bot'}}\n",
"88 {'_index': 'experiment', '_type': '_doc', '_id': '57', '_score': 1.0, '_source': {'tweet': 'べっぴんさんにおける四つ葉のクローバーの意味は「勇気、愛情、信頼、希望」なので、それぞれの単語をプリキュアに置き換えるとキュアカレッジ、キュアラブ、キュアトラスト、キュアホープかな。既に居そうな名前だな(わかる人だけわかれば良いです', 'username': 'mabo_jikkyou'}}\n",
"89 {'_index': 'experiment', '_type': '_doc', '_id': '58', '_score': 1.0, '_source': {'tweet': 'モンハンとかプリキュアと被ってリアタイできないけど、赤髪の子が一人称僕でやたら主人公と仲いいし、ハンターのオトモ可愛い', 'username': 'wakasiya3'}}\n",
"90 {'_index': 'experiment', '_type': '_doc', '_id': '59', '_score': 1.0, '_source': {'tweet': 'あっという間に今年のプリキュア映画やぁっ(*´ω`*)b🎵', 'username': 'moemoekyunn42'}}\n",
"91 {'_index': 'experiment', '_type': '_doc', '_id': '60', '_score': 1.0, '_source': {'tweet': 'なぜオレはプリキュア待機をしていたんだ…?', 'username': 'heron109'}}\n",
"92 {'_index': 'experiment', '_type': '_doc', '_id': '61', '_score': 1.0, '_source': {'tweet': 'プリキュアLOVE', 'username': 'kaasan_hoshiga_'}}\n",
"93 {'_index': 'experiment', '_type': '_doc', '_id': '62', '_score': 1.0, '_source': {'tweet': '録画予約 [10/29(土) 19:30~20:00] ドキドキ!プリキュア\\u3000第23話 [BS11:TvRock V0.9u twrd3 twrd32820]', 'username': 'cicata_xxx'}}\n",
"94 {'_index': 'experiment', '_type': '_doc', '_id': '63', '_score': 1.0, '_source': {'tweet': 'プリキュアの時間です', 'username': 'hlo1pmylenssog4'}}\n",
"95 {'_index': 'experiment', '_type': '_doc', '_id': '64', '_score': 1.0, '_source': {'tweet': '【定期】銀魂/弱ペダ/物語/けいおん/おそ松さん/まどマギ/AB!/デュラ/あの花/氷菓/犬夜叉/あずまんが/女神さま/よつばと/うる星/プリキュア/いぬぼく/etc 好きなアニメあったらRT RTしてくれた人全員フォローします 相互希望', 'username': 'abcderu'}}\n",
"96 {'_index': 'experiment', '_type': '_doc', '_id': '65', '_score': 1.0, '_source': {'tweet': 'おはようございます。 天気はいいのに、めっちゃ寒い。これでは花も元気なくしてしまう。 これって彼らがこの世界まで侵攻始めてるって事なのか。 早いとこプリキュアに追い払ってもらわないと!\\u3000#precure (放射冷却現象) https://t.co/ZsNWgN5rQF', 'username': 'nya820002'}}\n",
"97 {'_index': 'experiment', '_type': '_doc', '_id': '66', '_score': 1.0, '_source': {'tweet': '明日のこの時間はテレ朝系列で「ドキドキプリキュア」が放送されるわ。みんな忘れずに見なさい。\\u3000\\u3000\\u3000#precure #dokidokiprecure #プリキュア', 'username': 'cure_ace_aguri'}}\n",
"98 {'_index': 'experiment', '_type': '_doc', '_id': '67', '_score': 1.0, '_source': {'tweet': 'プリキュアの時間だー!', 'username': 'yamato2367'}}\n",
"99 {'_index': 'experiment', '_type': '_doc', '_id': '68', '_score': 1.0, '_source': {'tweet': '【定期】 プリキュアと少々鉄道が好きです! 趣味が合う方フォローミーです~', 'username': 'cureplato'}}\n",
"100 {'_index': 'experiment', '_type': '_doc', '_id': '69', '_score': 1.0, '_source': {'tweet': 'プリキュアの流行りの応援上映か……気になるし行きたい気もするし、会場でミラクルライト(過去のもの)貰ってその上映で振れるんだよな…… ポスターも欲しいし❗ ただ……翌日仕事だよな……そんで5000円……😱 悩む🌀😖 &gt;RT', 'username': 'setunaicoca'}}\n"
]
}
],
"source": [
"query = {\n",
" \"query\": {\n",
" \"match_all\": {}\n",
" },\n",
" \"fields\": [\"_id\"],\n",
" \"size\": 100\n",
"}\n",
"url = 'http://localhost:9200/experiment/_doc/_search?scroll=1m'\n",
"response = requests.get(url, data=json.dumps(query), headers=headers)\n",
"search_hits = json.loads(response.text)['hits']['hits']\n",
"\n",
"for idx, hit in enumerate(search_hits):\n",
" print(idx + 1, hit)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'_index': 'experiment',\n",
" '_type': '_doc',\n",
" '_id': 'n7kMZ3cBe-XfFcbgxeJ6',\n",
" 'found': False}"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"query = {\n",
" \"query\": {\n",
" \"match_all\": {}\n",
" },\n",
"}\n",
"url = 'http://localhost:9200/experiment/_doc/n7kMZ3cBe-XfFcbgxeJ6'\n",
"response = requests.get(url, data=json.dumps(query), headers=headers)\n",
"search_hits = json.loads(response.text)\n",
"search_hits"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'_index': 'experiment',\n",
" '_type': '_doc',\n",
" '_id': 'nrkMZ3cBe-XfFcbgxeJt',\n",
" '_version': 1,\n",
" 'result': 'created',\n",
" '_shards': {'total': 2, 'successful': 1, 'failed': 0},\n",
" '_seq_no': 2050550,\n",
" '_primary_term': 1}"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data = {\n",
" \"username\": \"unchi\",\n",
" \"tweet\": 'uchin'\n",
"}\n",
"url = 'http://localhost:9200/experiment/_doc/nrkMZ3cBe-XfFcbgxeJt'\n",
"response = requests.put(url, data=json.dumps(data), headers=headers)\n",
"search_hits = json.loads(response.text)\n",
"search_hits"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Response [200]>"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# we can delete this experimental index to prevent occupying space\n",
"response = requests.delete('http://localhost:9200/experiment')\n",
"response\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment