1

我将 ElasticSearch v6.4 与 Nest(v.6.4.2) 和 ElasticSearch.Net(v.6.4.2) 库一起使用。我正在尝试将 Search API 与我的 Raw Json 查询一起使用。

这是我的 JSON 查询模板:

    var jsonQuery  = @"{
      "_source": {
        "exclude": [],
        "include": []
      },
      "query": {
        "bool": {
          "should": [
            [
              { 
                "multi_match": {
                  "query": "*",
                  "analyzer": "standard",
                  "type": "most_fields",
                  "fields": []
                }
              },
              {
                "multi_match": {
                  "query": "*",
                  "analyzer": "standard",
                  "type": "most_fields",
                  "fuzziness": 1,
                  "prefix_length": 3,
                  "fields": []
                }
              }
            ]
          ],
          "filter": {
            "bool": {
              "must": [
                { "term": { "xx": "yy" } }
              ],
              "must_not": [],
              "should": [
                {
                  "bool": {
                    "must": [
                      { "term": { "xx": "yy" } },
                      { "term": { "xx": "yy" } },

                    ]
                  }
                },
                {
                  "bool": {
                    "must": [
                      { "range": { "xx": { "gte": yy1, "lte": yy2 } } }
                    ]
                  }
                }
              ]
            }
          }
        }
      },
      "from": 0,
      "size": 500,
      "min_score": 0.0,
      "sort": [],
      "aggs": {}
    }"

首先,当我将此查询与 .Raw() 一起使用时,它会返回无效低级调用的错误。

其次,当我使用以下函数获取结果时:

var responseData = _connectionToEs.EsClient(_esInstanceUrl, _indexName).LowLevel.Search<myClass>(jsonQuery);

我收到以下错误: The type 'myClass' cannot be used as type parameter 'TResponse' in the generic type or method IElasticLowLevelClient.Search<TResponse>(PostData, SearchRequestParameters). There is no implicit reference conversion from 'myClass' to 'Elasticsearch.Net.IElasticsearchResponse'

我被困在这个问题上很长一段时间了,还没有找到任何解决方案。如何使用原始 JSON 查询与 ElasticSearch.Net 函数一起使用它是嵌套函数还是低级函数?请帮忙。提前致谢!!!

4

0 回答 0