【发布时间】:2021-09-13 01:56:08
【问题描述】:
我是 Elasticsearch 查询的新手,所以我不知道如何在 Visual Studio 中将此 SQL 查询转换为 Elasticsearch 查询:
WHERE
(x IS NOT NULL) AND (y IS NOT NULL) OR
(x IS NOT NULL) AND (z IS NOT NULL) OR
(x IS NOT NULL) AND (q IS NOT NULL)
我知道 Elasticsearch 查询应该是这样的,带有“应该”和“必须”,但我确信它与正确的语法相去甚远,而且 Visual Studio 给了我太多的红线,上面写着“名称Must/Exist/Field 在当前上下文中不存在”。
.Query(q => q
.Bool(m => m
.Should( s => s
.Must(
b => b.Exists(t => t.Field(y => y.x)),
b => b.Exists(t => t.Field(y => y.y))),
.Must(
b => b.Exists(t => t.Field(y => y.x)),
b => b.Exists(t => t.Field(y => y.z))),
.Must(
b => b.Exists(t => t.Field(y => y.x)),
b => b.Exists(t => t.Field(y => y.q))))
如果有人能帮助我找到将 SQL 查询转换为 Elasticsearch 的最佳方法,我将不胜感激。提前谢谢!
【问题讨论】:
标签: c# sql visual-studio elasticsearch