I want to show result based on highest matching keywords in descending order.
Below code shows result but not sorted in descending order.
Please help me to resolve this issue as I don't want to use full text index.
My code is as follows:
<%
Dim SearchWord, arrKeyWords, Cnt, tsearch, i
SearchWord = Trim(request("searcha"))
SearchWord = Replace(SearchWord, " and ", " ")
SearchWord = Replace(SearchWord, " in ", " ")
SearchWord = Replace(SearchWord, " or ", " ")
arrKeyWords = Split(SearchWord ," ")
%>
<%
If IsArray(arrKeyWords) Then
For i = 0 To (UBound(arrKeyWords)-1)
Dim objRSsg, objCmdsg, strsg
Set objCmdsg = Server.CreateObject("ADODB.Command")
Set objRSsg = Server.CreateObject("ADODB.Recordset")
Dim countItem, numPerPage, page, totalpages, totalRecs
countItem = 0
numPerPage = 50
objRSsg.cursorlocation = 3
If request("page") = "" Then
page = 1
Else
page = CLng(request("page"))
End If
strsg = "select rProd_name, r_id from reseller_prod " & _
"where rProd_name LIKE '%' + ? + '%' " & _
"union " & _
"select Prod_name, '' as r_id from product " & _
"where Prod_name LIKE '%' + ? + '%'"
With objCmdsg
.ActiveConnection = MM_connDUdirectory_STRING
.CommandText = strsg
.CommandType = adCmdText
.Parameters.Append(.CreateParameter("@sa1", adVarChar, adParamInput, 1000))
.Parameters.Append(.CreateParameter("@sa2", adVarChar, adParamInput, 1000))
.Parameters.Append(.CreateParameter("@sa3", adVarChar, adParamInput, 1000))
.Parameters.Append(.CreateParameter("@sa4", adVarChar, adParamInput, 1000))
.Parameters("@sa1").Value = arrKeyWords(i)
.Parameters("@sa2").Value = arrKeyWords(i)
.Parameters("@sa3").Value = arrKeyWords(i)
.Parameters("@sa4").Value = arrKeyWords(i)
End With
objRSsg.Open objCmdsg, , 1, 2
Next
End If
...
...
%>