在执行pyes脚本时报出以下异常 Traceback (most recent call last): File "indextest.py", line 18, in <module> conn.indices.put_mapping ("test-type", {'properties':mapping}, ["test-index"]) File "/usr/lib/python2.7/site-packages/pyes/managers.py _send_request('PUT', path, mapping, params=parameters) File "/usr/lib/python2.7/site-packages/pyes/ _send_request raise_if_error(response.status, decoded) File "/usr/lib/python2.7/site-packages/pyes
后来看到 elasticsearch ,真是亮瞎老夫的狗眼啊,这货直接可以用restful json操作又有pyes,pyelasticsearch这些已经封装好的操作库。 安装pyes pip install pyes 使用例子 #coding:utf-8 import pyes conn = pyes.ES(['127.0.0.1:9200'])#连接es conn.create_index test-index", "test-type") conn.default_indices=["test-index"]#设置默认的索引 conn.refresh()#刷新以获得最新插入的文档 q = pyes.TermQuery bill")#查询name中包含bill的记录 results = conn.search(q) for r in results: print #查询name中包含 百度 的数据 q = pyes.StringQuery (u"百 度",'name') results = conn.search(q) for r in results: print #查询name中包含 百度 或着 中度 的数据 q = pyes.StringQuery