久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

操作方法:對搜索結果進行排名

How-to: Ranking Search Results(操作方法:對搜索結果進行排名)
本文介紹了操作方法:對搜索結果進行排名的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個 webapp 開發(fā)問題,我已經(jīng)為它開發(fā)了一個解決方案,但我正在嘗試尋找其他想法來解決我所看到的一些性能問題.

I have a webapp development problem that I've developed one solution for, but am trying to find other ideas that might get around some performance issues I'm seeing.

問題說明:

  • 用戶輸入多個關鍵字/標記
  • 應用程序搜索令牌的匹配項
  • 每個令牌需要一個結果
    • 即,如果一個條目有 3 個令牌,我需要 3 次條目 id
    • 為令牌匹配分配 X 點
    • 根據(jù)點對條目 id 進行排序
    • 如果點值相同,則使用日期對結果進行排序

    我希望能夠做但還沒有弄清楚的是發(fā)送 1 個查詢,該查詢返回類似于 in() 結果的內(nèi)容,但為每個條目 id 的每個令牌匹配返回一個重復的條目 id已檢查.

    What I want to be able to do, but have not figured out, is to send 1 query that returns something akin to the results of an in(), but returns a duplicate entry id for each token matches for each entry id checked.

    有沒有比我正在做的更好的方法來做到這一點,即使用多個單獨的查詢對每個令牌運行一個查詢?如果是這樣,實現(xiàn)這些的最簡單方法是什么?

    Is there a better way to do this than what I'm doing, of using multiple, individual queries running one query per token? If so, what's the easiest way to implement those?

    編輯
    我已經(jīng)標記了條目,因此,例如,see spot run"的條目 id 為 1,三個標記,see"、spot"、run",它們位于單獨的標記表中,帶有與它們相關的條目 ID,因此表格可能如下所示:

    edit
    I've already tokenized the entries, so, for example, "see spot run" has an entry id of 1, and three tokens, 'see', 'spot', 'run', and those are in a separate token table, with entry ids relevant to them so the table might look like this:

    'see', 1 
    'spot', 1 
    'run', 1 
    'run', 2 
    'spot', 3 
    

    推薦答案

    您可以使用 MySQL 中的UNION ALL"在一個查詢中實現(xiàn)這一點.

    you could achive this in one query using 'UNION ALL' in MySQL.

    只需遍歷 PHP 中的令牌,為每個令牌創(chuàng)建一個 UNION ALL:

    Just loop through the tokens in PHP creating a UNION ALL for each token:

    例如,如果標記是x"、y"和z",您的查詢可能看起來像這樣

    e.g if the tokens are 'x', 'y' and 'z' your query may look something like this

    SELECT * FROM `entries` 
    WHERE token like "%x%" union all 
        SELECT * FROM `entries` 
        WHERE token like "%y%" union all 
            SELECT * FROM `entries` 
            WHERE token like "%z%" ORDER BY score ect...
    

    order 子句應該將整個結果集作為一個操作,這正是您所需要的.

    The order clause should operate on the entire result set as one, which is what you need.

    就性能而言,它不會那么快(我猜),但是對于數(shù)據(jù)庫而言,速度方面的主要開銷通常是從 PHP 向數(shù)據(jù)庫引擎發(fā)送查詢并接收結果.使用這種技術,這只會發(fā)生一次,而不是每個令牌一次,因此性能會提高,我只是不知道是否足夠.

    In terms of performance it won't be all that fast (I'm guessing), however with databases the main overhead in terms of speed is often sending the query to the database engine from PHP and receiving the results. With this technique this only happens once instead of once per token, so performance will increase, I just don't know if it'll be enough.

    這篇關于操作方法:對搜索結果進行排名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

    【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 色综合久久久 | 91精品国产乱码久久蜜臀 | 日韩高清一区 | 日韩欧美一区二区三区四区 | 国产免费一区二区 | 日本天堂一区 | 成人在线精品视频 | 久久亚洲国产 | 欧美日韩1区2区3区 欧美久久一区 | 久久国产欧美日韩精品 | 一区二区国产精品 | 欧美亚洲国产日韩 | 欧美999 | 久久亚洲欧美日韩精品专区 | a级免费观看视频 | 日韩在线观看中文字幕 | 在线国产99| 婷婷福利视频导航 | 国产在线精品一区二区 | 欧美中文在线 | 国产免费av网 | 国产在线区 | 91综合网| 亚洲精品一区二区久 | 日韩在线播放第一页 | 欧美.com | 欧美国产精品 | 国产一区二区三区在线看 | 综合激情网 | 国产成人精品一区二三区在线观看 | 欧美中文在线 | 欧美一级在线 | 激情91| 玖玖视频免费 | 日韩精品一| 91伊人 | 女人毛片a毛片久久人人 | 日本三级全黄三级三级三级口周 | 亚洲国产精品成人 | 亚洲视频中文字幕 | 国产综合久久久久久鬼色 |