我正在尝试使用elastic作为我的数据层,同时使用elastic来创建REST API。
以下是一些细节:
1.我的弹性指数:
Index Name : employee
{
"employee": {
"mappings": {
"master": {
"properties": {
"EMPLID": {"type": "string"},
"ENAME": {"type": "string”},
"SKILLS": {"type": "string”}
}
}
}
}
}
2.我的app.py文件
import eve
from eve_elastic import Elastic
config = {'DOMAIN': {}}
app = eve.Eve(__name__, config, data=Elastic)
app.run()
3.我的Settings.py文件
RESOURCE_METHODS = ['GET']
ITEM_METHODS = ['GET']
PUBLIC_RESOURCE_METHODS = ['GET']
PUBLIC_ITEM_METHODS = ['GET']
DOMAIN = {
'employee': {
'schema': {
'emplid': {
'type': 'string'
}
},
'datasource': {
'backend': 'elastic'
}
}
}
我的问题是app.py
和settings.py
应该添加的内容,以创建一个简单的REST API,它接受emplid
作为输入,并将ename
作为输出。
谢谢
答案 0 :(得分:0)
我的应用文件:
import eve
from eve_elastic import Elastic
app = eve.Eve(__name__, data=Elastic)
app.run()
我的设置文件:
RESOURCE_METHODS = ['GET']
ITEM_METHODS = ['GET']
PUBLIC_RESOURCE_METHODS = ['GET']
PUBLIC_ITEM_METHODS = ['GET']
employee={
'schema': {
'emplid': {'type': 'string'},
'ename': {'type': 'string'},
'skills': {'type': 'string'},
'datasource': {'backend': 'elastic'}
}
}
DOMAIN={
'employee': employee
}
现在我的下一步是写下我的第一个终点并使用网址http://:8080 / emp / 1来访问它?
谢谢