推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
SlipStupig
V2EX  ›  Python

Elasticsearch 5.x 如何做关联查询

  •  
  •   SlipStupig · Nov 9, 2017 · 4196 views
    This topic created in 3302 days ago, the information mentioned may be changed or developed.

    我有多个文档,用 uid 来关联

    eg:

    {
      "uid": 1
    "name":"andy",
    "age": 35
    }
    
    {
     "uid": 1
     "shop_list": [
    {"date": "2015-1", "product": "超级大雪糕"}
    ]
    }
    

    如何用一条语句可以查询关联一个用户的多个文档呢?

    6 replies  •  2017-11-09 17:09:21 +08:00
    Hieast
    Hieast
    Nov 9, 2017
    1
    看起来就是简单的 term 查询。
    SlipStupig
    SlipStupig
    OP
    Nov 9, 2017
    2
    @Hieast 我只搜索 name,想全搜索到
    mengzhuo
    mengzhuo
    Nov 9, 2017
    3
    最简单的 query 就好了啊,OP 你看不看文档的啊
    Morriaty
    Morriaty
    Nov 9, 2017
    4
    建一个包含所有信息的 index

    es 是没有 join 操作的
    dangyuluo
    dangyuluo
    Nov 9, 2017
    5
    我感觉你得放上你的数据结构,例如 mapping
    Hieast
    Hieast
    Nov 9, 2017
    6
    @SlipStupig 你这个应该是很基础的需求,没时间看英文文档的话可以看权威指南的中文版(只有 2.x 版),然后再结合新版的 api 使用。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2552 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 12:19 · PVG 20:19 · LAX 04:19 · JFK 07:19
    ♥ Do have faith in what you're doing.