简体   繁体   English

使用Ajax搜索页面(算法)

[英]Search Page with Ajax (algorithm)

I want to make a search page like google that when i input 'ex' then with the ajax we recognition that the user intend to input 'example' or 'exam' or ... what is the algorithm for making a page like this ? 我想制作一个类似于google的搜索页面,当我输入“ ex”然后使用ajax时,我们认识到用户打算输入“ example”或“ exam”或...,制作这种页面的算法是什么? is the query of mysql like : "SELECT * FROM users WHERE upper($field) LIKE'%$find%'" ? mysql的查询是这样的: "SELECT * FROM users WHERE upper($field) LIKE'%$find%'" Thanks in Advance . 提前致谢 。

the query is almost this 查询几乎是这个
mysql_query("select * from users where queryfield like '$q%' order by queryfield");
you may use jquery autocomplete to ease your work 您可以使用jQuery自动完成功能来简化工作

<input type="text" id="populate">
<script type="text/javascript">

   $(function() {

    $("#populate").autocomplete({
        url: 'search.php',
        cache: false,
        onItemSelect: function(item) {
            window.location.href=item.data;
            document.getElementById('populate').value='';

        },
    });

});


    </script>


for complete source: 完整的来源:
http://jqueryui.com/demos/autocomplete/#remote http://jqueryui.com/demos/autocomplete/#remote

I think it works like this, suppose we have two tables, one are the articles / links in demand, others are the key words 'search engine breaks', but what good these keywords? 我认为它是这样工作的,假设我们有两个表,一个是需求中的文章/链接,另一个是“搜索引擎中断”的关键字,但是这些关键字有什么用呢? to me, is a popularity index, because it is the most sought after, this index is based on that .. 对我来说,它是一种受欢迎程度指数,因为它是最受欢迎的指数,因此该指数基于该指数。

The more a person searches, eg ' i an legend ' or ' legend an i ', ' movie legend ', ' god is legend ' .. the word 'legend' was searched four times, and its index will be built based on this, but .. you have a limit order, they may have many words that have been sought, but did not even enter the search or in addition 人们搜索的次数越多,例如“ 我是传奇人物 ”或“ 我是传奇 人物 ”,“ 电影传奇人物 ”,“ 上帝就是传奇人物 ” ..单词“传奇”被搜索了四次,其索引将以此为基础,但是..您有一个限价单,他们可能搜索了许多单词,但没有输入搜索字词,或者另外

You will have to do something like this, create a table, where it will update every 25% of searches, the words .. when the user is typing, you show the suggestions. 您将必须执行类似的操作,创建一个表,该表将在每25%的搜索中更新一次,在用户键入内容时,单词..会显示建议。

You should do something, it would bring better results for those who use the search, however, you can resolve the suggest problem with jQuery Autocomplete 您应该做一些事情,它将为使用搜索的用户带来更好的结果,但是,您可以使用jQuery Autocomplete解决建议的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM