2016-12-28 10 views
5

Elastic Search 5.1 특정 필드의 값을 검색하기 위해 stored_fields 본문 인수 (이전 필드 인수의 새 이름)를 사용하여 기본 요청을합니다.신축성있는 검색 5.1 stored_fields가 요청한 필드를 반환하지 않는 이유는 무엇입니까?

하지만 내 요청이 _index, _type, _id를 제외하고 대답하고 _score

에 더 필드 값을주지 당신이 상황에 대한 샘플 보내기

내가 가진 인덱스 및 매핑 생성 :

PUT /base_well 
    { 
     "mappings": { 
      "person": { 
        "properties": { 
         "first_name":{ 
          "type": "string" 
         }, 
         "last_name":{ 
          "type": "string" 
         }, 
         "age":{ 
          "type": "long" 
         } 
        } 
      } 
     } 
    } 

을 채워집니다 :

내 요청 :

POST /base_well/person/_search 
{ 
    "stored_fields": ["first_name"] 

} 

그리고 요청 필드 fiest_person없이 나에게 answere을 제공 :

{ 
    "took": 4, 
    "timed_out": false, 
    "_shards": { 
     "total": 5, 
     "successful": 5, 
     "failed": 0 
    }, 
    "hits": { 
     "total": 8, 
     "max_score": 1, 
     "hits": [ 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFYzihcR_Z5VPUXUCL", 
      "_score": 1 
     }, 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFiv3acR_Z5VPUXUCa", 
      "_score": 1 
     }, 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFiwUKcR_Z5VPUXUCb", 
      "_score": 1 
     }, 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFYx2LcR_Z5VPUXUCI", 
      "_score": 1 
     }, 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFYyhScR_Z5VPUXUCJ", 
      "_score": 1 
     }, 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFYzIJcR_Z5VPUXUCK", 
      "_score": 1 
     }, 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFivgzcR_Z5VPUXUCZ", 
      "_score": 1 
     }, 
     { 
      "_index": "base_well", 
      "_type": "person", 
      "_id": "AVlFiw2qcR_Z5VPUXUCc", 
      "_score": 1 
     } 
     ] 
    } 
} 

누구는 그것을 나에게 설명 할 수 있으며 제발 어떻게 작동하는지?

+0

쿼리에''_source ': true'를 추가하면 소스가 보이나요? – Val

+0

아니요, 아마도 답변입니다 –

+0

질문에'stored_fields'라고 언급했기 때문에 당황 스럽습니다.하지만 쿼리의 어느 부분에도 표시되지 않습니다. – Val

답변

7

기본적으로 문서 필드는 저장되지 않습니다. 즉, 매핑에 각각에 대해 store: true을 지정하지 않아야합니다.

따라서 "stored_fields": ["first_name"]은 저장되지 않으므로 first_name 필드를 반환 할 수 없습니다.

대신 source filtering을 사용하고 쿼리에 "_source": ["first_name"]을 지정하면 작동합니다.