2

Elastic-Search python API (pyes) についての質問です。

curl を使用して非常に単純なテストケースを実行すると、すべてが期待どおりに動作するようです。

curl テストケースの説明は次のとおりです。

ES に存在する唯一のドキュメントは次のとおりです。

curl 'http://localhost:9200/test/index1' -d '{"page_text":"This is the text that was found on the page!"}

次に、「 found 」という単語が存在するすべてのドキュメントを ES で検索します。結果は OK のようです。

curl 'http://localhost:9200/test/index1/_search?q=page_text:found&pretty=true'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 0.15342641,
    "hits" : [ {
      "_index" : "test",
      "_type" : "index1",
      "_id" : "uaxRHpQZSpuicawk69Ouwg",
      "_score" : 0.15342641, "_source" : {"page_text":"This is the text that was found on the page!"}

    } ]
  }
}

ただし、python2.7 api (pyes) を使用して同じクエリを実行すると、何か問題が発生します。

>>> import pyes
>>> conn = pyes.ES('localhost:9200')
>>> result = conn.search({"page_text":"found"}, index="index1")
>>> print result
<pyes.es.ResultSet object at 0xd43e50>
>>> result.count()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyes/es.py", line 1717, in count
    return self.total
  File "/usr/local/pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyes/es.py", line 1686, in total
    self._do_search()
  File "/usr/local/pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyes/es.py", line 1646, in _do_search
    doc_types=self.doc_types, **self.query_params)
  File "/usr/local/pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyes/es.py", line 1381, in search_raw
    return self._query_call("_search", body, indices, doc_types, **query_params)
  File "/usr/local/pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyes/es.py", line 622, in _query_call
    return self._send_request('GET', path, body, params=querystring_args)
  File "/usr/local/pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyes/es.py", line 603, in _send_request
    raise_if_error(response.status, decoded)
  File "/usr/local/pythonbrew/pythons/Python-2.7.3/lib/python2.7/site-packages/pyes/convert_errors.py", line 83, in raise_if_error
    raise excClass(msg, status, result, request)
pyes.exceptions.IndexMissingException: [_all] missing

ご覧のとおり、pyes は結果オブジェクトを返しますが、何らかの理由で、そこにある結果の数を取得することさえできません。

ここで何が間違っているのでしょうか?

よろしくお願いします!

4

1 に答える 1

1

indexパラメータの名前が変更され、呼び出されなくなりindices、リストになりました。

>>> result = conn.search({"page_text":"found"}, indices=["index1"])
于 2012-09-04T09:12:49.113 に答える