推荐学习书目
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 · 4047 views
    This topic created in 3195 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
        1
    Hieast  
       Nov 9, 2017
    看起来就是简单的 term 查询。
    SlipStupig
        2
    SlipStupig  
    OP
       Nov 9, 2017
    @Hieast 我只搜索 name,想全搜索到
    mengzhuo
        3
    mengzhuo  
       Nov 9, 2017
    最简单的 query 就好了啊,OP 你看不看文档的啊
    Morriaty
        4
    Morriaty  
       Nov 9, 2017
    建一个包含所有信息的 index

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