【问题标题】:how to index the sql database for using Match Against query如何索引 sql 数据库以使用 Match Against 查询
【发布时间】:2011-11-14 19:16:11
【问题描述】:

我想在我的 sql 中使用 Match Against 查询来进行以下地理位置查询:-

SELECT location.lid, location_instance.uid, users.name
         , users.mail , location.latitude , location.longitude , users.picture, 
         ( 6371 * ACOS( COS( RADIANS($lat) ) * COS( RADIANS( location.latitude ) ) 
         * COS( RADIANS( location.longitude ) - RADIANS($lon) ) + SIN( RADIANS($lat) ) 
         * SIN( RADIANS( location.latitude ) ) ) ) AS distance
            from {location} LEFT JOIN {location_instance} ON location.lid = location_instance.lid 
            LEFT JOIN {users} ON location_instance.uid = users.uid WHERE MATCH (users.name) 
            AGAINST ('$search_term' IN BOOLEAN MODE) ORDER BY distance

但我想我最初必须在我的数据库中运行索引查询。请指导我很多网络人

编辑:

【问题讨论】:

    标签: mysql drupal phpmyadmin


    【解决方案1】:

    添加全文索引的sql:-

    alter table users add fulltext index (name);
    

    添加索引后:-

    show index from users;
    

    你应该看到类似的东西:-

    表:用户 非唯一:1 Key_name:名称 Seq_in_index: 1 列名:名称 排序规则:NULL 基数:??? 子部分:NULL 打包:NULL 空值: 索引类型:全文 评论:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-08
      • 2011-09-23
      • 1970-01-01
      • 2010-10-22
      • 2015-12-24
      • 1970-01-01
      • 2019-08-04
      • 1970-01-01
      相关资源
      最近更新 更多