dynamodbMap列表的ElasticSearch

l7mqbcuq  于 2021-06-13  发布在  ElasticSearch
关注(0)|答案(1)|浏览(307)

我把下面的dynamodb字段添加到ElasticSearch中。
索引:myindex
类型:mytype
mytpe的Map如下所示:

'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中查询Map列表的方法吗?
mkshixfv

mkshixfv1#

您可以在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()

相关问题