如何用sphinx实现颜色搜索?
使用 mysql 按主色搜索照片非常简单。假设照片最主要颜色的 r、g、b 值已经存储在数据库中,这可以通过以下方式实现:
SELECT * FROM colors
WHERE ABS(dominant_r - :r) < :threshold
AND ABS(dominant_g - :g) < :threshold
AND ABS(dominant_b - :b) < :threshold
我想知道,是否可以将颜色存储在 sphinx 中并执行使用sphinx搜索引擎进行查询?
谢谢!
searching a photo by dominant colors using mysql is quite simple. assuming that the r,g,b values of the most dominant colors of the photo is already stored in the database, this could be achieved for example by something like:
SELECT * FROM colors
WHERE ABS(dominant_r - :r) < :threshold
AND ABS(dominant_g - :g) < :threshold
AND ABS(dominant_b - :b) < :threshold
i wonder, if it's anyhow possible to store the colors in sphinx and perform the querying using the sphinx search engine?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经用狮身人面像搜索了颜色。就在那里 http://code.google.com/p/hppg/。它是如何运作的?
非常简单,对于每种颜色,我将其主色存储在数据库中。数据库表,用于sphinx索引,有名为“colors”的列,其内容按以下方式填充:
我在这里使用标记公式,以避免非常大的索引。计数是自定义托盘项目匹配的次数。它工作得很好,可以在项目主页找到一些实时站点的示例。这样我们就可以同时按颜色和关键字搜索:)。目前我仍在尝试以获得最佳结果......
I have done search for colors with sphinx. It's there http://code.google.com/p/hppg/. How it works?
Very simple, for each color I store it's dominant colors in database. Database table, witch is used for sphinx indexing, has column named "colors", it's content is filled in the following way:
I used tagging formula here, to avoid very big index. Count is the number of times custom pallete item was matched. It works just fine, some examples of live sites can be found at project home page. Such way we can search by color and keyword at the same time :). Currently I'm still experimenting to get best result of it...