我尝试修改现有的查询字符串以筛选指定的条件:现在查询字符串如下:
String bodycontent="{"
+" \"_source\": [\"@timestamp\",\"eqpid\",\"lotid\",\"stageid\",\"srvmethod\",\"parm_1\",\"apcack\",\"description\",\"host\",\"path\",\"action\"],"
+" \"query\": {"
+" \"query_string\" : {"
+" \"query\":\" lotid:"+q_lotid+" AND "+host_type+"\"}"
+" },"
+" \"sort\" : [{\"@timestamp\" : { \"order\" : \"desc\" }}]"
+"}";我想更改下面的查询条件:
query :
type:ams_log AND (alm_source:K*) AND (alm_id:TCS00004 OR alm_id:TCS00005 OR alm_id:TCS00007 OR alm_id:TCS00008 OR alm_id:TCS00009 OR alm_id:TCS00010 OR alm_id:TCS00011 OR alm_id:TCS00012 OR alm_id:TCS00013 OR alm_id:TCS00020 OR alm_id:TCS00024 OR alm_id:TCS00032)但是,我很困惑如何用斜杠\和双引号"修改查询字符串。我找不到规矩了,谢谢!
发布于 2020-12-28 10:30:47
\\\"System.out.println("\\ \"hello\"");输出:
\ "hello"
关于您的查询,似乎键和值都必须在引号"key":"value"之间。
String lotId="2020_A_88";
String type="apples";
String queryPart = "\"lotId\":\""+lotId+"\" AND \"type\":\""+type+"\"";
System.out.println(queryPart); "lotId":"2020_A_88" AND "type":"apples"
String example = String.format("Slash-> %s , Quotes-> %s", "\\" ,"\"name\"");
System.out.println(example);Slash-> \ , Quotes-> "name"
String s = "\\";
String q = "\"name\"";
System.out.println("Slash-> "+s+" , Quotes-> "+q);Slash-> \ , Quotes-> "name"
https://stackoverflow.com/questions/65476057
复制相似问题