![](/img/trans.png)
[英]c# nest for elasticsearch: how to convert query that updates particular field of elastic search document to nest?
[英]elasticsearch how to include a nested array field in a search query c#
我有一個彈性文檔,我需要在 Skillsm 全名電子郵件和反饋中搜索
"_source" : {
"applicantId" : 73,
"pmId" : 4,
"jobId" : 1,
"fullName" : "user user",
"email" : "gmail@gmail.com",
"phone" : "3024asfd148567",
"resumeContentLength" : 0,
"flag" : 0,
"note" : "",
"source" : "Uploaded",
"copiedJobId" : -1,
"skills" : "C#,Nodejs,MongoDb",
"applyDate" : "2020-06-05T09:51:48.8870000",
"dateLastActive" : "0001-01-01T00:00:00",
"attachments" : [
{
"id" : 695,
"fileName" : "27cd4643e2d91ac4c11997e772d3a4e7d8c.pdf",
"contentType" : "application/pdf",
"dateCreated" : "0001-01-01T00:00:00"
}
],
"feedbacks" : [{
"email" : "someuser@gmail.com",
"score" : -1,
"comment" : "Some text"
} ]
}
},
這是我的 C# 代碼
var xxx = client.Search<ElasticApplicant>(q => q.Index("hrm_applicants").Size(100)
.Query(x=>x.MultiMatch(p=>p.Fields(n=>n.Field(f=>f.Skills).Field(f=>f.ResumeContent))
.Query("համակարգիչ"))));
如何在查詢中包含嵌套數組字段?
我用這段代碼解決了這個問題。 彈性搜索 [7.9]
string keyword="keyword";
var searchResponse = client.Search<ElasticApplicant>(s => s
.Query(q => q
.Match(m => m
.Field(f => f.Skills)
.Query(keyword)
) || q
.Match(m => m
.Field(f => f.ResumeContent)
.Query(keyword)
) || q
.Nested(n => n
.Path(p => p.Feedbacks)
.Query(qq => qq.Match(m => m.Field(f => f.Feedbacks.First().Comment).Query(keyword))))
)
);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.