How to return total items of a Lucene query in Orchard

78 Views Asked by At

I have this query in OrchardCore to return paged result of Product content type:

{ 
  "track_total_hits": true,
  "from" : {{ from }}, "size" : {{ size }},
  "query": {
    "bool" : {
      "must" : [
        { "term" : { "Content.ContentItem.ContentType" : "Product" }},        
       { "term" : { "Content.ContentItem.Published" : "true" }},
        { "term" : { "Content.ContentItem.Latest" : "true" }},
        { "term" : { "LocalizationPart.Culture" : "{{culture}}" }},
        {
          "bool": {
            "must": [              
              { "match" : { "Content.ContentItem.FullText" : "{{ fulltext }}"}}
            ]
          }
        },
        
        {% if owner != "" and owner != null and owner != '*' %}
        { "term" : { "Content.ContentItem.Owner" : "{{ owner }}" } }
        {% endif %}
        {% if author != "" and author != null and author != '*' %}
        { "term" : { "Content.ContentItem.Author" : "{{ author }}" } }
        {% endif %}
      ]
    }
  },
  "sort": [
    { "Content.ContentItem.ModifiedUtc": { "order": "desc" } },
    { "Content.ContentItem.CreatedUtc": { "order": "desc" } }
  ]
}

As shown in the query track_total_hits is elasticsearch feature to return total hits but I do not know does it work in Orchard or not. When I run this query in GraphiQl of Orchard there is no data about total items. Moreover the schema part of this query is as below:

{
    "type": "ContentItem/Product"
}
0

There are 0 best solutions below