【发布时间】:2016-05-31 20:30:02
【问题描述】:
我有数字,我用concatenating double quoted 动态添加到列表中,并按如下方式放入代码中
ArrayList arrRespId = new ArrayList();
for (int i = 0; i < hitsCountRespId; i++)
{
arrRespId.Add("\"" + jsonRespId["aggregations"]["my_fields"]["buckets"][i]["key"].ToString() + "\"");
} //Adding all numbers in the list with double quoted
var strDouble = string.Join(",", arrRespId.ToArray()); //"5","6","7"
大家好,我有一个 lambda expression 的代码,它从 Elasticsearch 获取信息
var SearchAggregate = client.Search<string>(sd => sd
.Index("Index")
.Type("Table")
.Size(0)
.Query(q => q
.Bool(b => b
.Must(
m => m.Terms("QID", new[] { strDouble.tostring() }),
m => m.Terms("ProjectID", new[] { "50" }),
m => m.Terms("RespID", new[] { abc.ToString() })
//m => m.Terms("RespID", new[] { "1","2" })
)))));
但问题是当我将双引号字符串放在 lambda 表达式中时,它会占用 "\"5\",\"6\",\"7\",.... 而我的代码没有返回任何内容
感谢您的帮助!谢谢
【问题讨论】:
-
它应该是
"RespId": { "5","6","7","8",...请看图片 -
为什么要将字符串数组转换为包含大量转义引号的字符串?只需传递未转义字符串的数组即可。
-
以上是用于
ElasticSearch和Elasticsearch的lambda表达式查询,当我们发送没有双引号字符串时会抛出异常
标签: c# c#-4.0 elasticsearch lambda