小编Bij*_*kel的帖子

嵌套查询相当于以下 ElasticSearch 查询

我是 .net core 的新手。我使用https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/nest.html作为我的弹性搜索客户端。

我有以下用弹性搜索编写的查询:

{
    "query": {
        "bool":{
         "must":[
            {
               "term":{
                  "bookId.keyword":"c962ec04-6d25-4823-8e78-6d99d4072032"
               }
            },
            {
               "bool":{
                  "should":[
                     {
                        "match_phrase":{
                         "text":"Plants"
                        }
                     }
                  ]
               }
            }
         ]
      }
    }
}
Run Code Online (Sandbox Code Playgroud)

虽然我的 NEST 代码是:

{
    "query": {
        "bool":{
         "must":[
            {
               "term":{
                  "bookId.keyword":"c962ec04-6d25-4823-8e78-6d99d4072032"
               }
            },
            {
               "bool":{
                  "should":[
                     {
                        "match_phrase":{
                         "text":"Plants"
                        }
                     }
                  ]
               }
            }
         ]
      }
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我无法得到预期的结果。谁能帮我这个?

c# elasticsearch nest .net-core

5
推荐指数
1
解决办法
974
查看次数

标签 统计

.net-core ×1

c# ×1

elasticsearch ×1

nest ×1