hongcha
V2EX  ›  数据库

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

  •  
  •   hongcha · Jan 15, 2016 · 2244 views
    This topic created in 3948 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
    vietor
    Jan 15, 2016 via Android
    1
    加 type 字段之后分离的数据用不同字段名
    qgy18
    qgy18
    Jan 15, 2016
    2
    1 、只能加判断, elasticsearch 的 RESTful 接口对接口要求很严格;
    2 、设置 Mapping ,指定字段 type 为 int ;

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