2016-08-22 242 views
0

我有以下模式彈性搜索: 我已經縮寫大部分爲便於閱讀彈性搜索嵌套數組查詢

 { 
    "took": 56, 
    "timed_out": false, 

    "hits": { 

     "hits": [ 

     { 
      "_id": "2FREAL%2FShaarHanegev%2Faxis-ACCC8E43E0C6%2F20160314%2F16%2F20160314_164253_E23D_ACCC8E43E0C6%2F20160314_16%2F20160314_164253_8DA7_ACCC8E43E0C6.mkv%3A26.153_1508_1439_1763_1440", 
      "_source": { 
       "path": "2FREAL%2FShaar%2Faxis-ACCC8E43E0C6%2F20160314%2F16%2F20160314_164253_E23D_ACCC8E43E0C6%2F20160314_16%2F20160314_164253_8DA7_ACCC8E43E0C6.mkv%3A26.153_1508_1439_1763_1440", 
       "frameAttributes": { 

        "trackerId": "OB7E600", 

        "identities": [ 
        { 
         "_id": "Abel_Nachos_034841460", 
         "_score": 0.451906 
        }, 
        { 
         "_id": "judas_acorn_10000897", 
         "_score": 0.430024 
        }, 
        { 
         "_id": "regenald_barbish_10000452", 
         "_score": 0.41979 
        }, 
        { 
         "_id": "Matthew_Gordon_Douglas_0631B#1", 
         "_score": 0.412086 
        }, 
        { 
         "_id": "NewYork_NYC_Gina_Lob_10000566", 
         "_score": 0.407909 
        } 
        ] 
       }, 
       "originalVideoFullPath": "REAL/Shaar/axis-ACCC8E43E0C6/20160314/16/20160314_164253_E23D_ACCC8E43E0C6/20160314_16/20160314_164253_8DA7_ACCC8E43E0C6.mkv" 
      } 
     }, 
     { 

      "_id": "2FREAL%2FShaar%2Faxis-ACCC8E43E0C6%2F20160314%2F16%2F20160314_164253_E23D_ACCC8E43E0C6%2F20160314_16%2F20160314_164253_8DA7_ACCC8E43E0C6.mkv%3A26.393_1454_1457_1711_1454", 

      "_source": { 
       "path": "2FREAL%2FShaarHanegev%2Faxis-ACCC8E43E0C6%2F20160314%2F16%2F20160314_164253_E23D_ACCC8E43E0C6%2F20160314_16%2F20160314_164253_8DA7_ACCC8E43E0C6.mkv%3A26.393_1454_1457_1711_1454", 

       "frameAttributes": { 
        "trackerId": "OB7E600", 

        "identities": [ 
        { 
         "_id": "Levon_Ayrapetyan_10000036", 
         "_score": 0.432837 
        }, 
        { 
         "_id": "Patrick_sole_10001145", 
         "_score": 0.425161 
        }, 
        { 
         "_id": "TAI_YUNG_LEE_LOUIE_10002450", 
         "_score": 0.404628 
        }, 
        { 
         "_id": "Izak_Gold_10000159", 
         "_score": 0.400651 
        }, 
        { 
         "_id": "Takahiro_Friend_10001663", 
         "_score": 0.392012 
        } 
        ] 
       }, 
       "clockwiseRotation": 90, 
       "numberOfFrames": 0, 
       "originalVideoFullPath": "REAL/Shaar/axis-ACCC8E43E0C6/20160314/16/20160314_164253_E23D_ACCC8E43E0C6/20160314_16/20160314_164253_8DA7_ACCC8E43E0C6.mkv" 
      } 
     } 

     ] 
    } 
} 

編輯:我添加縮寫映射所請求

{ 
    "index1": { 
    "mappings": { 
     "objects": { 
     "properties": { 
      "_results": { 
      "type": "object" 
      }, 
      "cameraId": { 
      "type": "string" 
      }, 
      "cameraType": { 
      "type": "string" 
      }, 
      "date": { 
      "type": "date", 
      "format": "dateOptionalTime" 
      }, 
      "frameAttributes": { 
      "properties": { 
       "identities": { 
       "properties": { 
        "_id": { 
        "type": "string" 
        }, 
        "_score": { 
        "type": "double" 
        } 
       } 
       }, 
       "testPassed": { 
       "type": "boolean" 
       } 
      } 
      }, 
      "fraudType": { 
      "type": "string" 
      }, 
      "index": { 
      "type": "long" 
      }, 
      "path": { 
      "type": "string" 
      }, 
      "siteName": { 
      "type": "string", 
      "index": "not_analyzed" 
      } 
     } 
     } 
    } 
    } 
} 

我正在嘗試編寫一個查詢,以查找人員{NewYork_NYC_Gina_Lob_10000566}所在的所有視頻(id)。

回答

0

我沒有看到映射,所以這是一個查詢忽略可能的嵌套對象或父子關係。

GET your_index/_search 
{ 
"query": { 
    "bool": { 
     "must": [ 
      { 
       "term": { 
       "frameAttributes.identities._id": "NewYork_NYC_Gina_Lob_10000566" 
       } 
      } 
     ] 
    } 
    } 
} 
+0

失敗:(我加入的模式 –

+1

我覺得我用「嵌套」,但我不知道這是在ES的一個術語,原來不是嵌套它的對象,這是ES 1.5 BTW –

+0

米奇,根據在ES 1.5中(與實際版本相同),您應該將嵌套實體顯式定義爲「嵌套」(「type」:「嵌套」),更多信息請參考:(https: //www.elastic.co/guide/en/elasticsearch/guide/1.x/nested-mapping.html 據我所知,「對象」≠嵌套。 –