How to return only inner hits in nested field

Hi everyone,
Just like I mention in the title, I have data set with the mapping below which has nested field. I am trying to get data with inner hits which are match with the written query.

If I write "_source":false at the top level of the query this will only return inner hits. ( example )

Also in the documents says if I write inner_hits in the nested query part this will return only hit which are matched the query.

    {
  "mapping": {
    "properties": {
      "ekuNo": {
        "type": "long"
      },
      "idx": {
        "type": "long"
      },
      "logInsertionDate": {
        "type": "date"
      },
      "receiptDate": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "receiptDateTime": {
        "type": "date"
      },
      "receiptPayment": {
        "type": "nested",
        "properties": {
          "amount": {
            "type": "double"
          },
          "amountTL": {
            "type": "double"
          },
          "appBankColor": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "appBankName": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "appBkmId": {
            "type": "integer"
          },
          "appTeliumAppId": {
            "type": "integer"
          },
          "cardBankColor": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "cardBankName": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "cardTeliumAppId": {
            "type": "integer"
          },
          "cashAmount": {
            "type": "double"
          },
          "creditAmount": {
            "type": "double"
          },
          "ekuNo": {
            "type": "long"
          },
          "flags": {
            "type": "integer"
          },
          "groupByAppBankData": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "groupByCardBankData": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "groupByPaymentType": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "logInsertionDate": {
            "type": "date"
          },
          "paymentTypeDesc": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "receiptDateTime": {
            "type": "date"
          },
          "seqNo": {
            "type": "long"
          },
          "serialNo": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "type": {
            "type": "integer"
          },
          "zSeqNo": {
            "type": "long"
          }
        }
      },
      "receiptTime": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "seqNo": {
        "type": "long"
      },
      "serialNo": {
        "type": "text",
        "fields": {
          "keyword": {
            "type": "keyword",
            "ignore_above": 256
          }
        }
      },
      "zSeqNo": {
        "type": "long"
      }
    }
  }
}

Also Query is

    get receiptreport_direct/_search
{"from": 0 ,"size": 10, "sort" : [ ],"_source":false, "query": { "bool" : { "must": [{ "range": { "receiptDateTime": { "lte": "2018-02-01" } } },{ "range": { "receiptDateTime": { "gte": "2018-01-01" } } }, { "nested": { "path" : "receiptPayment", "query" : { "bool" : { "must" : [ { "script": { "script": "doc['receiptPayment.cardTeliumAppId'].value != doc['receiptPayment.appTeliumAppId'].value" } }] } }, "inner_hits":{} } }], "must_not": [], "should": [], "filter": [] } } }

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.