根据构件属性查询构件ID_文档_BIMFACE_BIM应用二次开发平台

API: 查询构件

GET | POST https://api.bimface.com/data/v2/query/elementIds
  1. 根据构件属性查询构件ID;
  2. 由于该请求需要Request Body,某些http client包不支持在GET方法中加入Request Body,故该接口同时支持GET和POST方法。

请求(Request)

Header
key value 示例
Authorization Bearer {accessToken} Bearer xxxx-xxxx-xxxx-xxxx
Content-Type application/json
Url Parameter

Request Body

主要是参考Elasticseach的Query DSL,可以看作是ES的DSL的子集,有些关键字有稍作改动

查询文件id为1124890692330272中,所有floor属性包含F的elementId
{
    "targetType":"file",
    "targetIds":["1124890692330272"],
    "query":{
        "contain":{
            "floor":"F"
        }   
    }
}
查询文件id为1124890692330272中,所有floor属性为F11的elementId
{
    "targetType":"file",
    "targetIds":["1124890692330272"],
    "query":{
        "match":{
            "floor":"F11"
        }   
    }
}
查询文件id为1124890692330272中,所有floor属性包含F并且family为标准的elementId
{
    "targetType":"file",
    "targetIds":["1124890692330272"],
    "query":{
        "boolAnd":[
            {"contain":{"floor":"F"}},
			{"match":{"family":"标准"}}
        ]   
    }
}
查询文件id为1124890692330272中,所有floor属性为F11或family为标准的elementId
{
    "targetType":"file",
    "targetIds":["1124890692330272"],
    "query":{
        "boolOr":[
            {"match":{"floor":"F11"}},
			{"match":{"family":"标准"}}
        ]   
    }
}
{
    "targetType":"file",
    "targetIds":["1124890692330272"],
    "query":{
       "boolOr" :  [
           { "match" : {"productID" : "KDKE-B-9947-#kL5"}}, 
           { "boolAnd" : [
               { "match" : {"productID" : "JODL-X-1937-#pV7"}}, 
               { "match" : {"price" : 30}} 
             ]
           }
         ]
   }
}

等价于
SELECT elementId
FROM   XXX
WHERE  productID      = "KDKE-B-9947-#kL5"
  OR (     productID = "JODL-X-1937-#pV7"
       AND price     = 30 )
比较复杂的查询示例
{
    "targetType":"file",
    "targetIds":["1124890692330272"],
    "query":{
        "contain":{
            "floor":"B01",
            "familyType":"标准"
        },
        "match":{"family":"family1"},
        "boolAnd":[
            {"match":{"categoryId":"id111"}},
			{"match":{"boundingBox.min.x":167899.9999999998}}
        ],
        "boolOr":[
            { "match" : {"productID" : "KDKE-B-9947-#kL5"}}, 
            { "boolAnd" : [
               { "match" : {"productID" : "JODL-X-1937-#pV7"}}, 
               { "match" : {"price" : 30}} 
             ]
           }
        ]   
    }
}
字段 类型 必填 描述 示例
targetType String Y 查询目标类型,只能是file或integration file
targetIds String[] Y 查询目标ID列表 [“1124890692330272”]
query Object Y 查询条件实体,由match、contain、boolAnd、boolOr组成
match Object N 精确匹配某个属性值 {“floor”:“F1”}
contain Object N 模糊匹配某个属性值 {“floor”:“1”}
boolAnd Object[] N 逻辑与查询,支持嵌套
boolOr Object[] N 逻辑或查询,支持嵌套
curl -X PUT 
-H "Authorization: bearer <your accessToken>" 
-H "Content-Type: application/json" 
-d '{"targetType":"file","targetIds":["1264863870984000","1124890692330272"], "query":{"contain":{"floor":"1"}}}' 
"https://api.bimface.com/data/v2/query/elementIds"

响应(Response)

HTTP STATUS

200

成功返回
{
  "code": "success",
  "data": [
    {
      "elementIds": ["644851","644853"],
      "targetId": "1264863870984000"
    },
    {
      "elementIds": ["644855","644857","644859"],
      "targetId": "1124890692330272"
    }
  ],
  "message": "message"
}
字段 类型 描述 示例
targetId String 文件ID或集成ID 1124890692330272
elementIds String[] 符合条件的构件ID列表 [“644851”,“644853”]
失败返回
{
    "code": "authentication.failed",
    "message": "Token was not recognized."
}
错误码
code 说明
system.error BIMFACE系统异常
authentication.failed API访问合法性校验失败
target.empty targetIds字段为空
token.query.empty query字段为空
query.class.unknown 不支持的query类型