1

I am using ElasticSearch v6.4 with Nest(v.6.4.2) and ElasticSearch.Net(v.6.4.2) Libraries. I am trying to use the Search API with my Raw Json Query.

Here is my template of JSON Query:

    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": {}
    }"

Firstly, when I am using this Query with .Raw() it is returing an error with Invalid Low Level Call.

Secondly, when I use the following function to get the results:

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

I am getting the following error: 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'.

I am stuck at this for quite some time and have not found any solution. How can I use the raw JSON query to use with the ElasticSearch.Net functions weather it be Nest functions or Low-Level functions? Please help. Thanks in Advance!!!

Avinash Prasad
  • 158
  • 1
  • 13

0 Answers0