338 lines
10 KiB
Text
338 lines
10 KiB
Text
{
|
|
"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": [
|
|
"<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>name</th>\n",
|
|
" <th>sdesc</th>\n",
|
|
" <th>desc</th>\n",
|
|
" <th>category</th>\n",
|
|
" <th>categorypath</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"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": [
|
|
"<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>name</th>\n",
|
|
" <th>sdesc</th>\n",
|
|
" <th>desc</th>\n",
|
|
" <th>category</th>\n",
|
|
" <th>categorypath</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>0</th>\n",
|
|
" <td>DENSO DTM82363 Thermostat, coolant</td>\n",
|
|
" <td>Thermostat, coolant</td>\n",
|
|
" <td><div class='criterias'><table class='criterias...</td>\n",
|
|
" <td>Thermostat</td>\n",
|
|
" <td>SparePart/Cooling System/Thermostat</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>1</th>\n",
|
|
" <td>ZF 1043.010.297 Automatic Transmission</td>\n",
|
|
" <td>Automatic Transmission</td>\n",
|
|
" <td><div class='criterias'><table class='criterias...</td>\n",
|
|
" <td>Automatic Transmission</td>\n",
|
|
" <td>SparePart/Transmission/Automatic Transmission/...</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>2</th>\n",
|
|
" <td>ZF 1060.040.003 Automatic Transmission</td>\n",
|
|
" <td>Automatic Transmission</td>\n",
|
|
" <td><div class='criterias'><table class='criterias...</td>\n",
|
|
" <td>Automatic Transmission</td>\n",
|
|
" <td>SparePart/Transmission/Automatic Transmission/...</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>3</th>\n",
|
|
" <td>VAICO V10-0131 Camshaft</td>\n",
|
|
" <td>Camshaft</td>\n",
|
|
" <td><div class='criterias'><table class='criterias...</td>\n",
|
|
" <td>Camshaft</td>\n",
|
|
" <td>SparePart/Engine/Engine Timing/Camshaft</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>4</th>\n",
|
|
" <td>VAICO V26-0302 Track Control Arm</td>\n",
|
|
" <td>Track Control Arm</td>\n",
|
|
" <td><div class='criterias'><table class='criterias...</td>\n",
|
|
" <td>Track Control Arm</td>\n",
|
|
" <td>SparePart/Powertrain & Suspension/Wheel Suspen...</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"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 <div class='criterias'><table class='criterias... Thermostat \n",
|
|
"1 <div class='criterias'><table class='criterias... Automatic Transmission \n",
|
|
"2 <div class='criterias'><table class='criterias... Automatic Transmission \n",
|
|
"3 <div class='criterias'><table class='criterias... Camshaft \n",
|
|
"4 <div class='criterias'><table class='criterias... Track Control Arm \n",
|
|
"\n",
|
|
" categorypath \n",
|
|
"0 SparePart/Cooling System/Thermostat \n",
|
|
"1 SparePart/Transmission/Automatic Transmission/... \n",
|
|
"2 SparePart/Transmission/Automatic Transmission/... \n",
|
|
"3 SparePart/Engine/Engine Timing/Camshaft \n",
|
|
"4 SparePart/Powertrain & Suspension/Wheel Suspen... "
|
|
]
|
|
},
|
|
"execution_count": 9,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"df_en.head()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": ".venv",
|
|
"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.10.6"
|
|
},
|
|
"orig_nbformat": 4
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 2
|
|
}
|