Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 如何使用ElasticSearch dsl py连接两个ElasticSearch索引?_Python 3.x_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Dsl - Fatal编程技术网 elasticsearch,dsl,Python 3.x,elasticsearch,Dsl" /> elasticsearch,dsl,Python 3.x,elasticsearch,Dsl" />

Python 3.x 如何使用ElasticSearch dsl py连接两个ElasticSearch索引?

Python 3.x 如何使用ElasticSearch dsl py连接两个ElasticSearch索引?,python-3.x,elasticsearch,dsl,Python 3.x,elasticsearch,Dsl,两份索引文件如下: class First(Document): class Index: name = 'first' case_id = Keyword() name = Text() class Second(Document): class Index: name = 'second' case_id = Keyword() status = Text() 我只想以SQL

两份索引文件如下:

class First(Document):

    class Index:
       name  = 'first'
       
   case_id = Keyword()
   name = Text()
   
class Second(Document):

    class Index:
       name  = 'second'
       
   case_id = Keyword()
   status = Text()
我只想以SQL格式执行如下查询

select * from first as f, second as s where s.case_id = f.case_id or s.status = 'xyz'
如何使用弹性搜索dsl查询来实现这一点

  • 弹性搜索不支持索引之间的联接

    原因:弹性搜索不是关系型的,非规范化数据应该存储在这里

    节录如下:

  • 在分布式系统中执行完整的SQL样式联接,如 Elasticsearch非常昂贵。相反,弹性搜索 提供两种连接形式,设计为水平缩放

  • 根据用例,使用嵌套或父/子映射来存储数据

    嵌套:如果嵌套文档的基数很低,并且索引需要大量读取

    父级/子级:如果子级的基数高于父级,则需要频繁更新父级/子级


  • 或者第三种选择:简单地对数据进行非规范化