【问题标题】:Multiple tag search engine多标签搜索引擎
【发布时间】:2014-09-20 22:11:46
【问题描述】:

每当我们使用主题标签进行搜索时,总是来自单个标签(Tumblr 除外)。 只是想知道是否有一个搜索引擎允许多个标签搜索? 我想使用不同的标签组合可能既有趣又准确:

#A  general results
#A, #B more specific
#A, #B, #C, #D close to the truth what attributes (tags) are given.

是否有任何网站以这种方式提供服务? 或者我怎样才能建立一个数据库来实现这一点? 非常感谢。

【问题讨论】:

    标签: database tags search-engine hashtag


    【解决方案1】:

    这是旧的,用 VB 编写的,但我认为这个原理对你有用。

    此代码并不完全限于具有所有标签的图片,而是将标签点击次数最多的图片推到顶部。

    此代码的工作原理是首先向用户展示最适合的内容,然后在下面为他们提供其他选项。你的 AND 场景会削减对 5 个标签中的 4 个有效的东西。在这种情况下,他们只会在标签下方显示 5 分中的 5 分。

    因此,如果您有一些带有以下标签的图像:

    鉴于:

    Image1 女人、狗、熊猫

    Image2 女人,电话,微笑

    Image3 人、狗、熊猫、香蕉

    Image4 男人,电话,微笑

    产量

    “电话微笑”的标签搜索会将 [Image2] 和 [Image4] 评分到列表顶部。

    “熊猫”的标签搜索只会产生 Image1 和 Image3。

    “man dog pandabanana”的标签搜索将产生 Image3 作为顶部,然后是 Image1,然后是 Image4。

    这个实现是为了根据标签找到最好的图像。

    您在自己的 SQL 数据库中创建 3 个表(如果您正在做网页或故事或为了您自己的清晰而更改图像):

    SQL 表:

    imageTag [INT ID, String Tag]
    imageImages [INT ID, NVARCHAR(2000) Path]
    imageConnections [INT TagID, INT ImageID]
    

    VB.NET 代码:

    'The beef of the SQL statement to get the scored results is here.
    Dim SearchString As String = 
        "SELECT it.path, count(it.path) AS cnt, it.Id, it.name, it.description, it.updated FROM imageimages AS it, imageconnections AS itt, imagetags AS t WHERE " + _
        "{REPLACE-TAG} AND t.id = itt.tagid AND it.id = itt.imageid " + _
        "GROUP BY Path, it.ID, it.name, it.description, it.updated ORDER BY cnt DESC"
    
    
    
    Dim keywords As String() = tstSearch.Text.Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries)
    
    If keywords.Length > 0 Then
    
        Dim strReplacement As String
    
        strReplacement = "( tag = '" + keywords(0) + "'"
    
        If keywords.Length > 1 Then
    
            For i As Integer = 1 To keywords.Length - 1
                strReplacement += " OR tag = '" + keywords(i) + "'"
            Next
    
        End If
    
        strReplacement += " )"
    
        SearchString = SearchString.Replace("{REPLACE-TAG}", strReplacement)
    
        dt = tran.GetDataTable(SearchString)
    
    End If
    

    【讨论】:

    • 谢谢卡特!如此实用的解决方案。我将尝试使用 VB.NET。谢谢大佬~
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-04
    • 1970-01-01
    • 1970-01-01
    • 2014-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多