2016-12-28 16 views
5

Elastic Search 5.1'de Belirli bir alanın değerini almak için saklanan_fields vücut argümanı (eski alanlar argümanı için yeni isim) ile temel istekte bulunuyorum.Elastik arama 5.1 neden saklanmış_fields sorulan alana dönmüyor?

Ama ricam _index, _type, _ID hariç cevap ve _score

hiçbir alan değerini vermek sana bağlam için örnek verin:

Birlikte indeksi ve eşlemesi oluşturmak:

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

Ben doldurmak:

POST /base_well/person 
     { 
      "first_name":"James", 
      "last_name" : "Mopo", 
      "Age" : 21 
     } 

    POST /base_well/person 
    { 
     "first_name":"Polo", 
     "last_name" : "Rodriguez", 
     "Age" : 36 
    } 

    POST /base_well/person 
    { 
     "first_name":"Marc Aurelien", 
     "last_name" : "Poisson", 
     "Age" : 26 
    } 

    POST /base_well/person 
    { 
     "first_name":"Mustapha", 
     "last_name" : "Bulutu M'Bo", 
     "Age" : 47 
    } 

İsteğimle:

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

} 

Ve istenen alan fiest_person olmadan bana bir answere vermek:

{ 
    "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 
     } 
     ] 
    } 
} 

Herkes bunu yapmak için bana açıklayabilir ve lütfen nasıl çalıştığını?

+0

Sorgunuzu '' _source ': true' eklerseniz kaynağı görüyor musunuz? – Val

+0

hayır, belki de cevap –

+0

Şaşkınım çünkü sorgunuzda 'storage_fields' den bahsediyorsunuz, ancak sorgunuzun herhangi bir yerinde göremiyorum. – Val

cevap

7

Varsayılan olarak, belge alanları saklanmaz, yani eşleştirmenizde, her biri için store: true belirtmezsiniz. Bu nedenle, "stored_fields": ["first_name"]"stored_fields": ["first_name"] , depolanmadığından first_name alanını iade edemeyecektir.

source filtering yerine kullanabilirsiniz ve sorgunuzda "_source": ["first_name"] belirtin, işinize yarayacak.

İlgili konular