gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 01:13:08 24 4
gpt4 key购买 nike

两个索引文件如下:

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'
如何使用 flex 搜索DSL查询进行查询?

最佳答案

  • Elastic Search不支持索引之间的联接
    原因: flex 搜索不是关系型的,应将非规范化数据存储在此处。
    摘自下面的elastic Doc:

  • Performing full SQL-style joins in a distributed system likeElasticsearch is prohibitively expensive. Instead, Elasticsearchoffers two forms of join which are designed to scale horizontally.


  • 根据用例,使用嵌套或父/子映射来存储数据。
    嵌套:如果嵌套文档的基数很低并且索引读取密集
    parent / child :如果 child 的基数非常高,并且 parent / child 需要经常更新
  • 关于python-3.x - 如何使用elasticsearch-dsl-py连接两个ElasticSearch索引?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63519201/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com