{ "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namesdescdesccategorycategorypath
\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
namesdescdesccategorycategorypath
0DENSO DTM82363 Thermostat, coolantThermostat, coolant<div class='criterias'><table class='criterias...ThermostatSparePart/Cooling System/Thermostat
1ZF 1043.010.297 Automatic TransmissionAutomatic Transmission<div class='criterias'><table class='criterias...Automatic TransmissionSparePart/Transmission/Automatic Transmission/...
2ZF 1060.040.003 Automatic TransmissionAutomatic Transmission<div class='criterias'><table class='criterias...Automatic TransmissionSparePart/Transmission/Automatic Transmission/...
3VAICO V10-0131 CamshaftCamshaft<div class='criterias'><table class='criterias...CamshaftSparePart/Engine/Engine Timing/Camshaft
4VAICO V26-0302 Track Control ArmTrack Control Arm<div class='criterias'><table class='criterias...Track Control ArmSparePart/Powertrain & Suspension/Wheel Suspen...
\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