2016-05-22 14 views
-1

私はelasticを使用してREST APIを作成している間、私のデータレイヤーとしてelasticを使用しようとしています。ここでEVE Elastic for Rest API

はいくつかの詳細です:

1.My弾性インデックス:

Index Name : employee 

{ 
    "employee": { 
    "mappings": { 
     "master": { 
     "properties": { 
      "EMPLID": {"type": "string"}, 
      "ENAME": {"type": "string”}, 
      "SKILLS": {"type": "string”} 
     } 
     } 
    } 
    } 
} 

2.My app.pyファイル

import eve 
from eve_elastic import Elastic 
config = {'DOMAIN': {}} 
app = eve.Eve(__name__, config, data=Elastic) 
app.run() 

3.My 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' 
     } 
    } 
} 

私の質問は何ですか? yをとsettings.pyに追加して、emplidを入力として受け入れ、enameを出力とする単純なREST APIを作成します。

おかげ

+0

私は、弾性部を知らないが、あなたは文書で、[クイックスタート](http://python-eve.org/quickstart.html)をチェックしていますか? – gcw

答えて

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 
     } 

私の最初のエンドポイントを書いて、URLを使ってアクセスするために私の次のステップがどうあるべきかhttp://:8080/emp/1?

おかげ