V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
KarlC
V2EX  ›  Elasticsearch

萌新请教一个 ES 字符数组过滤问题

  •  
  •   KarlC · 2021-06-22 09:18:40 +08:00 · 1467 次点击
    这是一个创建于 1010 天前的主题,其中的信息可能已经有所发展或是发生改变。
    索引中某个字段的值是字符数组,例如"test": ["test1", "test2"],查询的时候怎么过滤数组中某个值,只知道 long 类型可以直接过滤,但是这种复合类型似乎不行,mapping 是
    "mappings" : {
    "properties" : {
    "test" : {
    "type" : "text",
    "fields" : {
    "keyword" : {
    "type" : "keyword",
    "ignore_above" : 256
    }
    }
    }
    }
    }
    4 条回复    2021-06-22 13:17:48 +08:00
    misaka19000
        1
    misaka19000  
       2021-06-22 09:39:52 +08:00
    可以直接过滤的

    {"term":{"test":"test1"}}
    X0ray
        2
    X0ray  
       2021-06-22 10:44:38 +08:00
    跟基础类型一个查法
    KarlC
        3
    KarlC  
    OP
       2021-06-22 13:16:57 +08:00 via Android
    @misaka19000 懂了,谢谢
    KarlC
        4
    KarlC  
    OP
       2021-06-22 13:17:48 +08:00 via Android
    @X0ray 原来多个值也是可以分开过滤的,明白了,谢谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1013 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 19:30 · PVG 03:30 · LAX 12:30 · JFK 15:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.