加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

通过PHP为搜索创建索引

发布时间:2020-12-13 21:35:04 所属栏目:PHP教程 来源:网络整理
导读:如何使用 PHP搜索唯一的单词,以便我可以学习搜索的基础知识? 我在为问题制作多维数组时遇到了一些问题. 我的第一个unsuccessful attempt如下. #1 $result = pg_query_params ( $dbconn,"SELECT question_id,body FROM questions",array () );while ( $row =
如何使用 PHP搜索唯一的单词,以便我可以学习搜索的基础知识?

我在为问题制作多维数组时遇到了一些问题.

我的第一个unsuccessful attempt如下.

#1

$result = pg_query_params ( $dbconn,"SELECT question_id,body
    FROM questions",array () 
);

while ( $row = pg_fetch_array ( $result ) ) {
    $question_body [ $row['question_id'] ] ['body'] = $row['body'];
    $question_index = explode ( " ",$question_body[ $row['question_id'] ] ['body'] ); 
    $question_index = array_unique ( $question_index ); 
}                                                                                                   
var_dump( $question_index );

这段代码的问题在于它结合了每个问题中的单词.
似乎我不能使用爆炸,因为它似乎只制作一个单维数组.

我还运行以下代码试图获取question_id unsuccessfully.

#2

while ( $row = pg_fetch_array ( $result ) ) {
    $question_body [ $row['question_id'] ] ['body'] = $row['body'];
    $question_index[ $row['question_id'] ] = explode ( " ",$question_body[ $row['question_id'] ] ['body'] );
    $question_index[ $row['question_id'] ]= array_unique ( $question_index );
}
var_dump( $question_index );

解决方法

帮自己一个忙,看看 Zend_Search_Lucene.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读