我有一个内容为"test"的文本文件(UTF-8编码).我尝试从这个文件中获取字节数组并转换为字符串,但它包含一个奇怪的字符.我使用以下代码:
var path = @"C:\Users\Tester\Desktop\test\test.txt"; // UTF-8
var bytes = File.ReadAllBytes(path);
var contents1 = Encoding.UTF8.GetString(bytes);
var contents2 = File.ReadAllText(path);
Console.WriteLine(contents1); // result is "?test"
Console.WriteLine(contents2); // result is "test"
Run Code Online (Sandbox Code Playgroud)
conents1不同于contents2- 为什么?
我有一个名为"IndexModel"的类:
public class IndexModel
{
[ElasticProperty(Index= FieldIndexOption.NotAnalyzed, Store = true)]
public string ModelNumber{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)
以下是我如何设置弹性客户端:
var uri = new Uri("http://localhost:9200");
var config = new ConnectionSettings(uri);
var client = new ElasticClient(config);
client.Map<IndexModel>(m => m.MapFromAttributes());
Run Code Online (Sandbox Code Playgroud)
我可以看到响应的映射结果:
Request {
"indexmodel": {
"properties": {
"modelNumber": {
"type": "string",
"store": true,
"index": "not_analyzed"
},
}
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个这种类型的索引记录,"ModelNumber"属性的值是"test-123",以下是我的查询:
var result = client.Search<IndexModel>(s => s.Query(new TermQuery() { Field = Property.Path<IndexModel>(it => it.ModelNumber), Value = "test-123"}));
Run Code Online (Sandbox Code Playgroud)
这是我得到的最终映射请求:
Method: POST,
Url: http://localhost:9200/_search,
Request: {
"query": …Run Code Online (Sandbox Code Playgroud) 如何在azure blob存储中创建空文件夹就像工具"Azure Explorer"中的空文件夹一样