{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from elasticsearch import Elasticsearch\n",
"client = Elasticsearch(\"http://localhost:9200\")\n",
"client.info()\n",
"client.ping()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"resp = client.search(index=\"retromotion-indexer_development_products\",\n",
" body={\"_source\":[\"descriptions\",\"descriptionsSource\",\"nameSource\",\"shortDescriptionSource\",\"categoriesSource\"],\n",
" \"query\": {\"match_all\": {}}})\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Got 22329 Hits:\n"
]
}
],
"source": [
"print(\"Got %d Hits:\" % resp['hits']['total'])"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [],
"source": [
"df_eng = pd.DataFrame(columns=['name','sdesc','desc','category','categorypath'])\n",
"df_de = pd.DataFrame(columns=['name','sdesc','desc','category','categorypath'])"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" name | \n",
" sdesc | \n",
" desc | \n",
" category | \n",
" categorypath | \n",
"
\n",
" \n",
" \n",
" \n",
"
\n",
"
"
],
"text/plain": [
"Empty DataFrame\n",
"Columns: [name, sdesc, desc, category, categorypath]\n",
"Index: []"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df_eng.head()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"name_en=[]\n",
"name_de=[]\n",
"\n",
"sdesc_en=[]\n",
"sdesc_de=[]\n",
"\n",
"desc_en=[]\n",
"desc_de=[]\n",
"\n",
"cat_en=[]\n",
"cat_de=[]\n",
"\n",
"catpath_en=[]\n",
"catpath_de=[]\n",
"\n",
"for hit in resp['hits']['hits']:\n",
" for name in hit['_source']['nameSource']:\n",
" if (name[\"language\"]==\"en\"):\n",
" name_en.append(name[\"value\"])\n",
" else:\n",
" name_de.append(name[\"value\"])\n",
" \n",
" for sdesc in hit['_source']['shortDescriptionSource']:\n",
" if (sdesc[\"language\"]==\"en\"):\n",
" sdesc_en.append(sdesc[\"value\"])\n",
" else:\n",
" sdesc_de.append(sdesc[\"value\"])\n",
"\n",
" for desc in hit['_source']['descriptionsSource']:\n",
" if (desc[\"language\"]==\"en\"):\n",
" desc_en.append(desc[\"value\"])\n",
" else:\n",
" desc_de.append(desc[\"value\"])\n",
" \n",
" for cats in hit['_source']['categoriesSource']:\n",
" if (cats[\"language\"]==\"en\"):\n",
" cat_en.append(cats[\"label\"])\n",
" else:\n",
" desc_de.append(cats[\"label\"])\n",
"\n",
" if (cats[\"language\"]==\"en\"):\n",
" catpath_en.append(cats[\"path\"])\n",
" else:\n",
" catpath_de.append(cats[\"path\"])\n"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"df_en = pd.DataFrame({'name':name_en,\n",
" 'sdesc':sdesc_en,\n",
" 'desc':desc_en,\n",
" 'category':cat_en,\n",
" 'categorypath':catpath_en})\n",
"\n",
"\n",
"# df_de = pd.DataFrame({'name':name_de,\n",
"# 'sdesc':sdesc_de,\n",
"# 'desc':desc_de,\n",
"# 'category':cat_de,\n",
"# 'categorypath':catpath_de})"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" name | \n",
" sdesc | \n",
" desc | \n",
" category | \n",
" categorypath | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" DENSO DTM82363 Thermostat, coolant | \n",
" Thermostat, coolant | \n",
" <div class='criterias'><table class='criterias... | \n",
" Thermostat | \n",
" SparePart/Cooling System/Thermostat | \n",
"
\n",
" \n",
" | 1 | \n",
" ZF 1043.010.297 Automatic Transmission | \n",
" Automatic Transmission | \n",
" <div class='criterias'><table class='criterias... | \n",
" Automatic Transmission | \n",
" SparePart/Transmission/Automatic Transmission/... | \n",
"
\n",
" \n",
" | 2 | \n",
" ZF 1060.040.003 Automatic Transmission | \n",
" Automatic Transmission | \n",
" <div class='criterias'><table class='criterias... | \n",
" Automatic Transmission | \n",
" SparePart/Transmission/Automatic Transmission/... | \n",
"
\n",
" \n",
" | 3 | \n",
" VAICO V10-0131 Camshaft | \n",
" Camshaft | \n",
" <div class='criterias'><table class='criterias... | \n",
" Camshaft | \n",
" SparePart/Engine/Engine Timing/Camshaft | \n",
"
\n",
" \n",
" | 4 | \n",
" VAICO V26-0302 Track Control Arm | \n",
" Track Control Arm | \n",
" <div class='criterias'><table class='criterias... | \n",
" Track Control Arm | \n",
" SparePart/Powertrain & Suspension/Wheel Suspen... | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" name sdesc \\\n",
"0 DENSO DTM82363 Thermostat, coolant Thermostat, coolant \n",
"1 ZF 1043.010.297 Automatic Transmission Automatic Transmission \n",
"2 ZF 1060.040.003 Automatic Transmission Automatic Transmission \n",
"3 VAICO V10-0131 Camshaft Camshaft \n",
"4 VAICO V26-0302 Track Control Arm Track Control Arm \n",
"\n",
" desc category \\\n",
"0