From 9eea2e016cf8a8eb72321a57a8180a41e7757327 Mon Sep 17 00:00:00 2001 From: "yiruan@ebay.com" Date: Fri, 20 Sep 2019 14:33:45 +0800 Subject: [PATCH] use the env parms for app name and pwd --- .../movie-search/README.md" | 19 +++++++++++++++++-- .../ingest_tmdb_to_appserarch.py" | 7 +++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git "a/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/README.md" "b/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/README.md" index cd3ae44..375900a 100644 --- "a/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/README.md" +++ "b/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/README.md" @@ -1,4 +1,5 @@ -课程demo +# 电影搜索服务 +## 课程demo ``` 安装配置 app-search.yml: @@ -8,4 +9,18 @@ allow_es_settings_modification: true action.auto_create_index: ".app-search-*-logs-*,-.app-search-*,+*" -``` \ No newline at end of file + + + +准备数据,使用python 2.7 +APP_SEARCH_NAME=tmdb APP_SEARCH_PWD=private-dtcda1pdruoq2hvwqe8rhz1x python ./ingest_tmdb_to_appserarch.py + +# 使用最新版本的 node +nvm list +nvm use default + +``` + +## 补充阅读 +- APP Search Release - https://www.elastic.co/blog/elastic-app-search-is-now-generally-available +- Search UI - https://www.elastic.co/blog/search-ui-1-0-0-released?baymax=web&elektra=search-ui-webinar diff --git "a/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/ingest_tmdb_to_appserarch.py" "b/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/ingest_tmdb_to_appserarch.py" index 0cea0a3..c362363 100644 --- "a/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/ingest_tmdb_to_appserarch.py" +++ "b/part-5/\345\256\236\346\210\2301-\347\224\265\345\275\261\346\220\234\347\264\242\346\234\215\345\212\241/movie-search/ingest_tmdb_to_appserarch.py" @@ -1,6 +1,9 @@ import requests import json +import os +APP_NAME= os.getenv('APP_SEARCH_NAME') +APP_PWD = os.getenv('APP_SEARCH_PWD') def extract(): f = open('./tmdb.json') @@ -19,8 +22,8 @@ def index_all(movieDict={}): def index_doc(doc): content=[] content.append(doc) - resp = requests.post("http://localhost:3002/api/as/v1/engines/tmdb/documents", - headers={"content-type":"application/json","Authorization": "Bearer private-o5waw7vawazryrxce6ktu6dr"}, + resp = requests.post("http://localhost:3002/api/as/v1/engines/"+APP_NAME+"/documents", + headers={"content-type":"application/json","Authorization": "Bearer "+APP_PWD}, data=json.dumps(content)) print resp