.net C#Elasticsearch嵌套转义空格字符
我想在querystring中转义空白字符。 我的代码是.net C#Elasticsearch嵌套转义空格字符,.net,
elasticsearch,nest,.net,
elasticsearch,Nest,我想在querystring中转义空白字符。 我的代码是 var node = new Uri("http://localhost:9200"); const string indexName = "evaluationdev5"; var settings = new ConnectionSettings( node, defaultIndex: indexName );
var node = new Uri("http://localhost:9200");
const string indexName = "evaluationdev5";
var settings = new ConnectionSettings(
node,
defaultIndex: indexName
);
var client = new ElasticClient(settings);
var indexExist = client.IndexExists(indexName);
if (!indexExist.Exists)
{
var response = client.CreateIndex(indexName);
}
var person = new Person
{
Id = "1",
Firstname = "john smith",
Lastname = "hendrick"
};
var person2 = new Person
{
Id = "2",
Firstname = "smith john",
Lastname = "hendrick"
};
client.Index(person, x => x.Index(indexName));
client.Index(person2, x => x.Index(indexName));
var result = client.Search<Person>(s => s
.Explain()
.From(0)
.Size(10)
.Query(q => q
.QueryString(qs => qs
.OnFields(new[]{"firstname","lastname"})
.Query(@"joh*\ smith")
.DefaultOperator(Operator.And)
)
)
);
我的查询是joh*\smith。我只想得到“约翰·史密斯”。但结果是空的。
此外,我尝试使用quotes querystring“joh*smith”但结果仍然为空。
我该怎么办 我不知道你想做什么。。。如果你能解释更多想要的结果,我可以帮你you@dzomba,我想转义空白字符。所以,在查询字符串中我写“joh*\smith”。结果必须是“约翰·史密斯”。我还尝试使用引号查询字符串“\”joh*smith\”,结果仍然为空。我不明白。为什么不使用约翰·史密斯??你用了什么样的分析仪?
public class Person
{
public string Id { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
}