Elasticsearch on DynamoDB 地图列表

Elasticsearch on DynamoDB List of Maps

我将以下 DynamoDB 字段添加到 Elastic Search。

索引:MYINDEX

类型:我的类型

MYTPE映射如下:

'roadmapParams': {
    'properties': {'L': {
         'properties': {'M': {
             'properties': {'project_id': {
               'properties': {'S': {
                  'fields': {
                    'keyword': {'ignore_above': 256,'type': 'keyword'}
                   },
                  'type': 'text'}}
              }, 
         }}}}}}
          

为了搜索 project_id 字段,我对 url 执行了以下查询: https://my_domain.com/MYINDEX/MYTYPE

"query": {
            "nested": {
                "path": "roadmapParams",
                "query": {
                    "regexp": {
                        "roadmapParams.L.M.project_id.S": partial_match
                    }
                }
            }
        },

这是在DDB中查询地图列表的方式吗?

您可以为 ES 6.0 及更高版本执行此操作。

from elasticsearch import Elasticsearch, RequestsHttpConnection
from elasticsearch_dsl import Search

# use aws4auth to make auth
# host is without https://

es = Elasticsearch(hosts=[{'host': host, 'port': 443}],
                       http_auth=auth,
                       use_ssl=True,
                       verify_certs=True,
                       connection_class=RequestsHttpConnection)

s = Search.from_dict({
        "query": {
            "regexp": {
                "roadmapParams.L.M.project_id.S": partial_match
            }
        },
    }).index('MYINDEX').using(es)

response = s.execute()