Nest 中的 ElasticSearch 多重匹配
ElasticSearch Multi-Match in Nest
我有这个有效的 DSL 查询。它 returns 结果符合预期。
GET /filedocuments/_search
{
"query": {
"multi_match": {
"query": "abc",
"fields": ["fileName", "metadata"]
}
}
}
但是,当它在下面的 NEST 库中运行时,returns 没有结果。我错过了什么?
var response = await _elasticClient.SearchAsync<FileDocument>(s => s
.Query(q => q
.MultiMatch(c => c
.Fields(f => f.Field(p => p.FileName).Field(p => p.Metadata))
.Query("abc")
)
)
);
这是映射:
"fileName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
和
"metadata" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
转成.ToUpper()后解决
我有这个有效的 DSL 查询。它 returns 结果符合预期。
GET /filedocuments/_search
{
"query": {
"multi_match": {
"query": "abc",
"fields": ["fileName", "metadata"]
}
}
}
但是,当它在下面的 NEST 库中运行时,returns 没有结果。我错过了什么?
var response = await _elasticClient.SearchAsync<FileDocument>(s => s
.Query(q => q
.MultiMatch(c => c
.Fields(f => f.Field(p => p.FileName).Field(p => p.Metadata))
.Query("abc")
)
)
);
这是映射:
"fileName" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
和
"metadata" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
转成.ToUpper()后解决