A
A
Alexey Belov2020-08-27 20:00:36
Amazon Web Services
Alexey Belov, 2020-08-27 20:00:36

How to use begin_with and contains together in DynamoDB?

def search(self, key, value):
        expression = Attr(key).begins_with(value)

        response = self.table.scan(
            FilterExpression=expression,
        )
        print(response)

        return response.get('Items')

{
  "id": "ORPH:1446",
  "names": [
    "Ring chromosome 22 syndrome",
    "Ring 22",
    "Ring chromosome 22",
    "r(22) syndrome"
  ]
}


There is approximately the same code on boto3 and an entry in the dynamo, I'm trying to look for a value in the list that begins, for example, with "Ring with". That is, I have a part of a phrase with which I want to find all the values ​​in the names list that begin with it.

I don’t think that the combination of begin_with and contains is the best solution here, but so far I haven’t come up with anything

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question