V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
hongcha
V2EX  ›  数据库

php 导数据进 elasticsearch 遇到了两个问题,求助

  •  
  •   hongcha · Jan 15, 2016 · 1758 views
    This topic created in 3765 days ago, the information mentioned may be changed or developed.

    1 、由于数据类型不匹配导致,
    主要问题是数据库中部分字段用 serialize 序列化,用 unserialize 解出来有的是数组,有的是 false ,目前加个判断解决?
    2 、由于导入后成了字符串,使用 elasticsearch 的 sum 求和 filed 失败?

    现在跪求哪位大神有通用的解决方案???

    3 replies    2016-01-20 14:00:00 +08:00
    vietor
        1
    vietor  
       Jan 15, 2016 via Android
    加 type 字段之后分离的数据用不同字段名
    qgy18
        2
    qgy18  
       Jan 15, 2016
    1 、只能加判断, elasticsearch 的 RESTful 接口对接口要求很严格;
    2 、设置 Mapping ,指定字段 type 为 int ;

    另外我上周帮人看 elasticsearch php client 时,发现它的文档好多地方有误,不知道改了没。
    hongcha
        3
    hongcha  
    OP
       Jan 20, 2016
    @qgy18 嗯,感谢,最近用了 https://github.com/NLPchina/elasticsearch-sql 查询起来还比较好
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   917 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 21:35 · PVG 05:35 · LAX 14:35 · JFK 17:35
    ♥ Do have faith in what you're doing.