I'm creating a site that allows users to submit quotes. How would I go about creating a (relatively simple?) search that returns the most relevant quotes?
For example, if the search term was "turkey" then I'd return quotes where the word "turkey" appears twice before quotes where it only appears once.
(I would add a few other rules to help filter out irrelevant results, but my main concern is that.)
Everyone is suggesting MySQL fulltext search, however you should be aware of a HUGE caveat. The Fulltext search engine is only available for the MyISAM engine (not InnoDB, which is the most commonly used engine due to its referential integrity and ACID compliance).
So you have a few options:
1。 The simplest approach is outlined by Particle Tree。 You can actaully get ranked searches off of pure SQL (no fulltext, no nothing). The SQL query below will search a table and rank results based off the number of occurrences of a string in the search fields:
SELECT
SUM(((LENGTH(p.body) - LENGTH(REPLACE(p.body, 'term', '')))/4) +
((LENGTH(p.body) - LENGTH(REPLACE(p.body, 'search', '')))/6))
AS Occurrences
FROM
posts AS p
GROUP BY
p.id
ORDER BY
Occurrences DESC
edited their example to provide a bit more clarity
Variations on the above SQL query, adding WHERE statements (WHERE p.body LIKE '%whatever%you%want'), etc. will probably get you exactly what you need.
2。 You can alter your database schema to support full text. Often what is done to keep the InnoDB referential integrity, ACID compliance, and speed without having to install plugins like Sphinx Fulltext Search Engine for MySQL is to split the quote data into it's own table. Basically you would have a table Quotes that is an InnoDB table that, rather than having your TEXT field "data" you have a reference "quote_data_id" which points to the ID on a Quote_Data table which is a MyISAM table. You can do your fulltext on the MyISAM table, join the IDs returned with your InnoDB tables and voila you have your results.
3。 安装 狮身人面像。 Good luck with this one.
Given what you described, I would 高度 recommend you take the 1st approach I presented since you have a simple database driven site. The 1st solution is simple, gets the job done quickly. Lucene will be a bitch to setup especially if you want to integrate it with the database as Lucene is designed mainly to index files not databases. Google custom site search just makes your site lose tons of reputation (makes you look amateurish and hacked), and MySQL fulltext will most likely cause you to alter your database schema.
文章标题:《Simple Online and Realtime Tracking with a Deep Association Metric》 文章地址:https://arxiv.org/abs/1703.07402 文章代码:https://github.com/abewley/sort 1. 简介 Deep SORT 仍然是一种基于检测的跟踪技术,与 SORT 类似,不过改进了匹配策略,...
1 Using Eclipse 1) Create project using archetype: maven-archetype-webapp 2) Update Build Path Using JDK-1.7 and Compiler Level to 1.7 &...
1.线性 来源 -------------------------------- 上图最后两行注释错了,differencexp为目前离升到下一级还有多少经验,totaldifference为当前等级所需升级经验。 比如从3级升到4级中,玩家当前经验条为320/700,则totaldifference为700,differencexp为380,两者相减为320。 在Excel上的表现 ------...
Here are the rules: if you read this post all the way through, you have to deploy a smart contract on your private Ethereum blockchain yourself. I give you all the code I used here in Github so you ha...
1, JMS message producer 使用WebListener是为了能部署到GlassFish, 这样就可以使用@Resource注入 当然,connectionFactory 和 topic要在glassfish中配置好 接下来就是通过JMS API发送消息了,非常简单: 2, JMS Message Consumer part &nb...
SORT: A Simple, Online and Realtime Trackerhttps://github.com/abewley/sort abewley/sort Simple, online, and realtime tracking of multiple objects in a video sequence....
1 javax.servlet.Servlet 接口 (1)接口包含五个方法: Public void init(ServletCongig config) Public void service(ServletRequest request, ServletResponse response) Public void destory() Public void ServletConfig get...
A Simple Web Server Web Server也称作HTTP server,用于客户端和服务器端HTTP通信。Java-base的webserver 主要使用java.net.Socket and java.net.ServerSocket. 1 HTTP协议介绍(Hypertest Transfer Protocol)  ...
函数都有prototype属性,它指向原型对象。 实例对象有__proto__属性,它指向对象原型 每一个原型对象都有constructor输赢,指向构造函数,每一个原型对象又具有__proto__属性,这个指向Object.prototype.在这里插入图片描述...
2.Dubbo简介 2.1 什么是dubbo Dubbo是一款高性能、轻量级的开源Java RPC框架,它提供了三大核心能力:面向接口的远程方法调用,智能容错和负载均衡,以及服务自动注册和发现。 2.2 流程图 Provider : 暴露服务的服务提供方。 Consumer : 调用远程服务的服务消费方。 Registry : 服务注册与发现的注册中心。 Monito...
I'm currently trying out the google cloud messaging service with its sample application "Guestbook." https://developers.google.com/cloud/samples/mbs/ I'm attempting to send notifications tha...
Now I came across an article that distinguishes between an Asynchronous function and Synchronous functions. From my understanding of the different examples and explanations, synchronous functions are ...
Good day all I'm busy creating a small costing calculator for the signage department. I'm not getting the calculator to output the amount. Brief Description: You enter the height and width and then wh...
I have 3 models created with Flask-SQLalchemy: User, Role, UserRole role.py: user.py: user_role.py: If I try (in the console) to get all users via User.query.all() I get AttributeError: 'NoneType' obj...
I have many particles that follow an stochastic process in parallel. For each particle, there is a PRNG associated to it. The simulation must go through many repetitions to get average results. For ea...