0

So I need to retrieve records based on a field called "cash_transfer_ids" which is a python list. I want to retrieve all records whose cash_transfer_ids contain a specific id value (a string). What should the query be look like? Should I use match or term query?

Example: I want to retrieve any record whose cash_transfer_ids field contains 'abc' Then I may get record such as record 1: cash_transfer_ids:['abc'] record 2: cash_transfer_ids:['dfdfd', 'abc'] etc...

Thanks very much for any help!

Chong Sun
  • 67
  • 5

1 Answers1

0

if cash_transfer_ids is type keyword I try filter with Term.

   term = "abc"
    query = {
              "query": {
                "term": {
                  "cash_transfer_ids": {
                    "value": term
                  }
                }
              }
            }
    response = get_client_es().search(index="idx_test", body=query)
rabbitbr
  • 2,991
  • 2
  • 4
  • 17