2014-12-26 3 views
1

매핑의 일부 필드에 대해 쿼리를 실행하려고하면 빈 결과 집합이 표시됩니다. "히트": []. 여기 특정 필드에 대한 ElasticSearch 쿼리 결과가 없습니다.

@classmethod 
def get_mapping(cls): 
    not_analyzed_str = {'type': 'string', 
         'index': 'not_analyzed'} 
    stake_fields = { 
     'id': {'type': 'integer'}, 
     'user': not_analyzed_str, 
     'user_id': {'type': 'integer'}, 
     'side': {'type': 'integer'}, 
     'amount': {'type': 'double'}, 
     'created': {'type': 'date'}, 
     'address': not_analyzed_str, 
    } 
    return { 
     'properties': { 
      'id': {'type': 'integer'}, 
      'description': {'type': 'string', 
          'analyzer': 'snowball'}, 
      'group': not_analyzed_str, 
      'state': not_analyzed_str, 
      'type': not_analyzed_str, 
      'currency': not_analyzed_str, 
      'username': not_analyzed_str, 
      'user_id': {'type': 'integer'}, 
      'expires': {'type': 'date'}, 
      'created': {'type': 'date'}, 
      'stakes_acception_end': {'type': 'date'}, 
      'winner': {'type': 'integer'}, 
      'stakes': {'type': 'nested', 
         'properties': stake_fields}, 
     } 
    } 

내 쿼리입니다 :

curl -XGET '_http://my.ip/main/core_bet/_search' -d '{ 
    "query": { 
     "nested" : { 
      "path":"stakes", 
      "query" : { 
       "bool": { 
        "should": [{ 
         "match": {"user_id": 2} 
        }] 
       } 
      } 
     } 
    } 
}' 

그리고 아무것도 얻을 여기 내 매핑입니다. I가 "일치"값을 변경할 때 { "면": 0},이 얻을 :

{ 
    "username": "DenisDavydov", 
    "expires": "2014-12-28T17:53:00+00:00", 
    "user_id": 1, 
    "description": "[bet-engine] 0 bugs (2014-12-28 19:53)", 
    "created": "2014-12-24T17:53:37.722558+00:00", 
    "stakes_acception_end": "2014-12-27T17:53:00+00:00", 
    "winner": null, 
    "currency": "xxx/xxx", 
    "state": "fresh", 
    "group": "", 
    "type": "0_bugs", 
    "id": 45, 
    "stakes": [ 
    { 
     "user_id": 2, 
     "created": "2014-12-26T14:24:52.565039+00:00", 
     "id": 1, 
     "amount": 12, 
     "user": "admin", 
     "address": "xxxxxxxxxxx", 
     "side": 0 
    }, 
    { 
     "user_id": 2, 
     "created": "2014-12-26T14:52:02.709043+00:00", 
     "id": 2, 
     "amount": 2, 
     "user": "admin", 
     "address": "xxxxxxxxx", 
     "side": 0 
    } 
    ] 
} 

을 그리고 인덱스 레코드의 일치 "USER_ID"를 포함한다는 것을 분명 : 2, 그래서 뭐가 잘못? 어떻게 해결할 수 있습니까?

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html#query-dsl-nested-query 그래서

curl -XGET '_http://my.ip/main/core_bet/_search' -d '{ 
    "query": { 
     "nested" : { 
      "path":"stakes", 
      "query" : { 
       "bool": { 
        "should": [{ 
         "match": {"stakes.user_id": 2} 
        }] 
       } 
      } 
     } 
    } 
}' 

확실히 작동합니다 -

+0

{ "stakes.user_id": 2} –

답변

0

는 문서에 따라, 당신은 전체 경로를 링크를 제공해야합니다.

+0

시도 해 주실 수 있나요? 고맙습니다! –

관련 문제