2017-07-06 13 views
0

私たちは記事&を編集しました。特定の著者によって最後に編集された記事の数を確認する必要があります。弾性検索ネストされた一致最後の値

データ:

{ 
    "Article" : [ 
     { 
     "id" : 12 
     "title" : "An article title", 
     "categories" : [1,3,5,7], 
     "tag" : ["elasticsearch", "symfony",'Obtao'], 
     "author" : [ 
      { 
       "firstname" : "Francois", 
       "surname": "francoisg", 
       "id" : 18 
      }, 
      { 
       "firstname" : "Gregory", 
       "surname" : "gregquat" 
       "id" : "2" 
      } 
     ] 
     } 
    }, 
    { 
     "id" : 13 
     "title" : "A second article title", 
     "categories" : [1,7], 
     "tag" : ["elasticsearch", "symfony",'Obtao'], 
     "author" : [ 
      { 
       "firstname" : "Gregory", 
       "surname" : "gregquat", 
       "id" : "2" 
      }, 
      { 
       "firstname" : "Francois", 
       "surname": "francoisg", 
       "id" : 18 
      } 
     ] 
     } 
} 

要求データ: URL:http://localhost:9200/book/articles/_count/

For example `Gregory` & `Francois` should get one article as count. 

私は唯一&が結果を得る最初のオブジェクトを比較する方法を教えてください。

答えて

0

私たちは直接フィルタリングできませんが、最後に編集した著者の余分なプロパティを追加することでこの問題を解決することができます。

{ 
    "Article" : [ 
     { 
     "id" : 12 
     "title" : "An article title", 
     "categories" : [1,3,5,7], 
     "tag" : ["elasticsearch", "symfony",'Obtao'], 
     "author" : [ 
      { 
       "firstname" : "Francois", 
       "surname": "francoisg", 
       "id" : 18, 
       "is_last_edited_staff": true 
      }, 
      { 
       "firstname" : "Gregory", 
       "surname" : "gregquat" 
       "id" : "2", 
       "is_last_edited_staff": false 
      } 
     ] 
     } 
    }, 
    { 
     "id" : 13 
     "title" : "A second article title", 
     "categories" : [1,7], 
     "tag" : ["elasticsearch", "symfony",'Obtao'], 
     "author" : [ 
      { 
       "firstname" : "Gregory", 
       "surname" : "gregquat", 
       "id" : "2", 
       "is_last_edited_staff": true 
      }, 
      { 
       "firstname" : "Francois", 
       "surname": "francoisg", 
       "id" : 18, 
       "is_last_edited_staff": false 
      } 
     ] 
     } 
} 
関連する問題