#6. 查询"empName"为"李华"的数据 GET es_employer/_search { "query": { "term": { "empName": "李华" } } }这段代码对不对
时间: 2023-11-08 22:06:47 浏览: 85
这段代码是正确的,可以查询到"empName"为"李华"的数据。如果想要查询多个条件,可以使用bool查询,例如:
```
GET es_employer/_search
{
"query": {
"bool": {
"must": [
{
"term": {
"empName": "李华"
}
},
{
"range": {
"salary": {
"gte": 5000
}
}
}
]
}
}
}
```
这个查询可以同时查询"empName"为"李华"且"salary"大于等于5000的数据。
相关问题
$("#h_box").on("click","#sendNextUsersM",function(){ var rows = me.datatable.rows(".selected").data().toArray(); if(rows.length ==1){ var is_valid = rows[0].IS_VALID; if(is_valid!="Y"){ wj_fun.wj_confirm_init("校验未通过,不可以发送!"); return; } //var item_key = rows[0].ITEM_KEY; //zjptWorkFlow(item_key,query); var tempSql = " select WF_VIEW_URL,WF_MODIFY_URL from XSR_XZ_EX_XLS_CONFIG where xls_code = '"+rows[0].XLS_CODE+"' "; var sqlResult = getForm.getSqlForms({"sql":tempSql}); var dpSql = " select d.dp_name from Xsr_Xz_Ba_Ou_Dp_All d where d.dp_id = "+rows[0].DP_ID; var dpResult = getForm.getSqlForms({"sql":dpSql}); var param = { "H_DESC": rows[0].INV_H_NAME, "VENDOR_SITE": "", "EMP_TYPE": "", "XLS_CODE": rows[0].XLS_CODE, "WF_VIEW": zx_session_vars["rootPath"]+"/"+sqlResult.WF_VIEW_URL, "WF_MODIFY_URL": zx_session_vars["rootPath"]+"/"+sqlResult.WF_MODIFY_URL, "WF_VIEW_URL": zx_session_vars["rootPath"]+"/"+sqlResult.WF_VIEW_URL, "WF_JBR_ID": "", "OU_ID": rows[0].OU_ID, "OU_NAME": rows[0].OU_NAME, "DP_NAME": dpResult.DP_NAME, "INV_H_NAME":rows[0].INV_H_NAME, "INV_H_CODE": rows[0].INV_H_CODE, "INV_H_VAL": rows[0].INV_H_VAL, "PAY_H_VAL": rows[0].INV_H_VAL, "WITH_TAX_VAL": rows[0].INV_H_VAL, "LOGINNAME": rows[0].BXR, "JBRXM":rows[0].EMPNAME, "DP_ID": rows[0].DP_ID, "EMP_NAME": rows[0].EMPNAME, "DP_CODE": "", "p_table_name": "xsr_xz_ex_inv_h", "p_primary_column": "INV_H_ID", "e_business_id": rows[0].INV_H_ID }; var callback = function () { //执行完成之后的回调函数,刷新表格 query(); wj_fun.tip_block({ "title": "流程提交成功!" }); }; wf_submit(rows[0].ITEM_TYPE, rows[0].ITEM_KEY, rows[0].AUDIT_STATUS, param,callback, true) }else{ wj_fun.wj_confirm_init("请选择一条数据!"); return ; } });
这段代码是一个JavaScript函数的定义。当id为"h_box"的元素中的id为"sendNextUsersM"的元素被点击时,会触发该函数。
函数内部首先获取被选中的行数据,并判断是否只选中了一行。如果不止选中了一行或者没有选中任何行,则会弹出提示信息。
如果只选中了一行,并且该行的IS_VALID属性不等于"Y",则会弹出提示信息"校验未通过,不可以发送!"。
接下来,通过执行SQL查询获取一些数据,并将这些数据存储在变量sqlResult和dpResult中。
最后,构建一个包含各种参数的param对象,并调用wf_submit函数,将param作为参数传递给它。wf_submit函数可能执行一些操作,然后调用回调函数callback,在完成后刷新表格,并显示一个提示信息"流程提交成功!"。
请注意,由于代码片段提供的不完整,缺少了一些定义和调用的部分,所以无法完全理解代码的功能。如果需要更多信息,请提供完整的代码片段。
简化如下SQL:SELECT e.empName,e.ts,f.archermindNum,f.departureTimeMax,f.departureTimeMin,f.departureTimeAvg,f.departureTimeTotal from (select b.empName,count(clockDate) as ts from (SELECT empName,clockDate,COUNT(clockDate) from r_empmachineclock_data_analysis where clockDate between "2023-05-01" and "2023-05-30" GROUP BY empName,clockDate) b group by b.empName) e ,(select max(departureTime) as departureTimeMax,min(departureTime) as departureTimeMin,ROUND(avg(departureTime)) as departureTimeAvg,sum(departureTime) as departureTimeTotal,empName,archermindNum from r_empmachineclock_data_analysis where departureTime >0 and clockDate between "2023-05-01" and "2023-05-30" group by archermindNum) f where e.empName = f.empName
以下是简化后的SQL查询语句:
```
SELECT
e.empName,
e.ts,
f.archermindNum,
MAX(f.departureTime) AS departureTimeMax,
MIN(f.departureTime) AS departureTimeMin,
ROUND(AVG(f.departureTime)) AS departureTimeAvg,
SUM(f.departureTime) AS departureTimeTotal
FROM
(
SELECT
empName,
COUNT(clockDate) AS ts
FROM
(
SELECT
empName,
clockDate,
COUNT(clockDate)
FROM
r_empmachineclock_data_analysis
WHERE
clockDate BETWEEN "2023-05-01" AND "2023-05-30"
GROUP BY
empName,
clockDate
) b
GROUP BY
empName
) e
JOIN (
SELECT
empName,
archermindNum,
departureTime
FROM
r_empmachineclock_data_analysis
WHERE
departureTime > 0
AND clockDate BETWEEN "2023-05-01" AND "2023-05-30"
) f
ON e.empName = f.empName
GROUP BY
e.empName,
e.ts,
f.archermindNum
```
该查询使用了两个子查询,其中第一个子查询计算了每个员工的工作天数,第二个子查询计算了每个员工的出勤情况。通过内连接将这两个结果集合并,并使用GROUP BY对结果进行分组,以便得到每个员工的出勤统计信息。
阅读全文