Search part of a website

Discussion in 'ASP .Net' started by Mel, Mar 23, 2010.

  1. Mel

    Mel Guest

    I have a private website (portal) that our sales representatives have
    access to. I have approx. 1GB of documents such as training manuals,
    marketing documents, technical information sheets, etc. located in a
    "Library" folder which contains lots of sub-folders and files and is
    located beneath the root folder. I want to allow the user to easily
    search this information; file name and file content key word
    searching. How would I implement this on my website?

    Please note, I want the users to search this area of the website only,
    searching the rest of the website is not necessary. I am using
    Asp.net 2.0, VB.net, VS 2008.
     
    Mel, Mar 23, 2010
    #1
    1. Advertising

  2. Mel

    Patrice Guest

    You could use Index Server (know perhaps as Windows Search) to index those
    documents. You may need third party "filters" to be able to index third
    party documents. Then you can use ADO.NET to run a query against those
    indexed documents.

    Try :
    http://www.c-sharpcorner.com/Upload...xServer11262005045132AM/UsingIndexServer.aspx
    --
    Patrice

    "Mel" <> a écrit dans le message de groupe de discussion
    : ...
    > I have a private website (portal) that our sales representatives have
    > access to. I have approx. 1GB of documents such as training manuals,
    > marketing documents, technical information sheets, etc. located in a
    > "Library" folder which contains lots of sub-folders and files and is
    > located beneath the root folder. I want to allow the user to easily
    > search this information; file name and file content key word
    > searching. How would I implement this on my website?
    >
    > Please note, I want the users to search this area of the website only,
    > searching the rest of the website is not necessary. I am using
    > Asp.net 2.0, VB.net, VS 2008.
    >
     
    Patrice, Mar 24, 2010
    #2
    1. Advertising

  3. Mel

    Mel Guest

    On Mar 24, 5:19 am, "Patrice" <http://scribe-en.blogspot.com/> wrote:
    > You could use Index Server (know perhaps as Windows Search) to index those
    > documents. You may need third party "filters" to be able to index third
    > party documents. Then you can use ADO.NET to run a query against those
    > indexed documents.
    >
    > Try :http://www.c-sharpcorner.com/UploadFile/sushil saini/UsingIndexServ...
    > --
    > Patrice
    >
    > "Mel" <> a écrit dans le message de groupe de discussion
    > : ...
    >
    >
    >
    > > I have a private website (portal) that our sales representatives have
    > > access to.  I have approx. 1GB of documents such as training manuals,
    > > marketing documents, technical information sheets, etc. located in a
    > > "Library" folder which contains lots of sub-folders and files and is
    > > located beneath the root folder.  I want to allow the user to easily
    > > search this information; file name and file content key word
    > > searching.  How would I implement this on my website?

    >
    > > Please note, I want the users to search this area of the website only,
    > > searching the rest of the website is not necessary.  I am using
    > > Asp.net 2.0, VB.net, VS 2008.- Hide quoted text -

    >
    > - Show quoted text -


    Okay, I think I am on the right track. I was able to create a new
    indexing service, called "Library" on my web server. I turned on
    "Generate Abstracts" and I also installed iFilter (from Adobe Acrobat)
    so the indexing service will also return results from PDF files.

    Now I am trying to make a new ASP.net web page that uses that indexing
    service to perform the searching. I am referring to the website link
    you provided and trying to make it work in Visual Basic language and
    Asp.net 2.0 (.NET framework 3.5). If anyone else can offer some other
    examples that would be excellent.
     
    Mel, Mar 24, 2010
    #3
  4. Mel

    Patrice Guest


    > Now I am trying to make a new ASP.net web page that uses that indexing
    > service to perform the searching. I am referring to the website link
    > you provided and trying to make it work in Visual Basic language and
    > Asp.net 2.0 (.NET framework 3.5). If anyone else can offer some other
    > examples that would be excellent.


    I found a KB article that exists in both C# and VB :
    http://support.microsoft.com/kb/820105/en-us (How to use an ASP.NET
    application to query an Indexing Service catalog by using Visual Basic
    ..NET).

    Though a bit old it should bit be very similar and even perhaps identical
    for .NET 2.0.

    --
    Patrice
     
    Patrice, Mar 24, 2010
    #4
  5. Mel

    Mel Guest

    On Mar 24, 12:14 pm, "Patrice" <http://scribe-en.blogspot.com/> wrote:
    > > Now I am trying to make a new ASP.net web page that uses that indexing
    > > service to perform the searching.  I am referring to the website link
    > > you provided and trying to make it work in Visual Basic language and
    > > Asp.net 2.0 (.NET framework 3.5).  If anyone else can offer some other
    > > examples that would be excellent.

    >
    > I found a KB article that exists in both C# and VB :http://support.microsoft.com/kb/820105/en-us(How to use an ASP.NET
    > application to query an Indexing Service catalog by using Visual Basic
    > .NET).
    >
    > Though a bit old it should bit be very similar and even perhaps identical
    > for .NET 2.0.
    >
    > --
    > Patrice


    My vPath is returning a NULL. The directory does in fact exist but
    the URL path is not there. The doctitle and filename are there but
    not the vPath. Any ideas why?

    'My Example Code
    'create a connection object and command object, to connect the
    Index Server
    Dim odbSearch As New
    System.Data.OleDb.OleDbConnection("Provider=""MSIDXS"";Data
    Source=""Library"";")
    Dim cmdSearch As New System.Data.OleDb.OleDbCommand()
    'assign connection to command object cmdSearch
    cmdSearch.Connection = odbSearch

    'Query to search a free text string in the catalog in the
    contents of the indexed documents in the catalog
    Dim searchText As String = btntxtSearch.Text.Replace("'",
    "''")
    cmdSearch.CommandText = "select doctitle, filename, vpath,
    rank, characterization from scope() where FREETEXT(Contents, '" &
    searchText & "') order by rank desc"

    odbSearch.Open()

    Try
    'execute search query
    Dim rdrSearch As System.Data.OleDb.OleDbDataReader =
    cmdSearch.ExecuteReader()
    'loop through each result and bind it to the repeater
    control
    While rdrSearch.Read()
    'Assemble the search result text and abstract
    getpagelink(rdrSearch(0).ToString(),
    rdrSearch(2).ToString(), rdrSearch(4).ToString()) 'rdrSearch(2)
    IS NULL, WHY?
    End While
    Catch ex As Exception
    lbl.Text = "Search Error: " & ex.Message & "<br>"
    End Try

    odbSearch.Close()
     
    Mel, Mar 25, 2010
    #5
  6. Mel

    Mel Guest

    On Mar 25, 9:08 am, Mel <> wrote:
    > On Mar 24, 12:14 pm, "Patrice" <http://scribe-en.blogspot.com/> wrote:
    >
    > > > Now I am trying to make a new ASP.net web page that uses that indexing
    > > > service to perform the searching.  I am referring to the website link
    > > > you provided and trying to make it work in Visual Basic language and
    > > > Asp.net 2.0 (.NET framework 3.5).  If anyone else can offer some other
    > > > examples that would be excellent.

    >
    > > I found a KB article that exists in both C# and VB :http://support.microsoft.com/kb/820105/en-us(Howto use an ASP.NET
    > > application to query an Indexing Service catalog by using Visual Basic
    > > .NET).

    >
    > > Though a bit old it should bit be very similar and even perhaps identical
    > > for .NET 2.0.

    >
    > > --
    > > Patrice

    >
    > My vPath is returning a NULL.  The directory does in fact exist but
    > the URL path is not there.  The doctitle and filename are there but
    > not the vPath.  Any ideas why?
    >
    > 'My Example Code
    >         'create a connection object and command object, to connect the
    > Index Server
    >         Dim odbSearch As New
    > System.Data.OleDb.OleDbConnection("Provider=""MSIDXS"";Data
    > Source=""Library"";")
    >         Dim cmdSearch As New System.Data.OleDb.OleDbCommand()
    >         'assign connection to command object cmdSearch
    >         cmdSearch.Connection = odbSearch
    >
    >         'Query to search a free text string in the catalog in the
    > contents of the indexed documents in the catalog
    >         Dim searchText As String = btntxtSearch.Text.Replace("'",
    > "''")
    >         cmdSearch.CommandText = "select doctitle, filename, vpath,
    > rank, characterization from scope() where FREETEXT(Contents, '" &
    > searchText & "') order by rank desc"
    >
    >         odbSearch.Open()
    >
    >         Try
    >             'execute search query
    >             Dim rdrSearch As System.Data.OleDb.OleDbDataReader =
    > cmdSearch.ExecuteReader()
    >             'loop through each result and bind it to the repeater
    > control
    >             While rdrSearch.Read()
    >                 'Assemble the search result text and abstract
    >                 getpagelink(rdrSearch(0).ToString(),
    > rdrSearch(2).ToString(), rdrSearch(4).ToString())       'rdrSearch(2)
    > IS NULL, WHY?
    >             End While
    >         Catch ex As Exception
    >             lbl.Text = "Search Error: " & ex.Message & "<br>"
    >         End Try
    >
    >         odbSearch.Close()


    I tried just "path" instead of "vpath" (which is virtual path) and I
    believe that will work.
     
    Mel, Mar 25, 2010
    #6
  7. Mel

    Patrice Guest

    > I tried just "path" instead of "vpath" (which is virtual path) and I
    > believe that will work.


    Based on the name vpath would be likely some kind of virtual directory
    (perhaps when you index content on another server using a share ?). So path
    should do it if you are on the same server...

    --
    Patrice
     
    Patrice, Mar 25, 2010
    #7
  8. Mel

    Mel Guest

    On Mar 25, 9:48 am, "Patrice" <http://scribe-en.blogspot.com/> wrote:
    > > I tried just "path" instead of "vpath" (which is virtual path) and I
    > > believe that will work.

    >
    > Based on the name vpath would be likely some kind of virtual directory
    > (perhaps when you index content on another server using a share ?). So path
    > should do it if you are on the same server...
    >
    > --
    > Patrice


    Got it. Almost done, however, when I release my new awesome search
    page to the web server the Next Page linkbutton doesn't work; it
    returns an error listed below. The code does work on my local
    computer while debugging but does not work on the web server. Ever
    had this problem? I don't use the ViewState much so I may need to
    read up on that.... Just thought I would post in case you have ever
    had this same issue.

    Server Error in '/' Application: Index was out of range. Must be non-
    negative and less than the size of the collection.
    Parameter name: index

    Example Code:
    Public Class Library
    Inherits System.Web.UI.Page
    Protected values As New ArrayList()
    Public cnt As Integer

    Public Property CurrentPage() As Integer
    Get
    Dim o As Object = Me.ViewState("_CurrentPage")
    ' look for current page in ViewState
    If o Is Nothing Then
    Return 0
    Else
    ' default to showing the first page
    Return CInt(o)
    End If
    End Get

    Set(ByVal value As Integer)
    Me.ViewState("_CurrentPage") = value
    End Set
    End Property

    Protected Sub cmdNext_Click(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles cmdNext.Click
    ' Set viewstate variable to the next page
    CurrentPage += 1
    ' Reload control
    btnSearch_Click(sender, e)
    End Sub

    'Execute the search
    Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
    System.EventArgs) Handles btnSearch.Click
    ''Reset to page 1 as a new search is performed
    If sender.text.ToString = "search" Then
    CurrentPage = 0
    End If

    ' Show Prev or Next buttons upon searching
    cmdPrev.Visible = True
    cmdNext.Visible = True

    cnt = 1
    If btntxtSearch.Text.Trim() = "" Then
    btnClear_Click(sender, e)
    Else
    lbl.Text = ""
    Search()
    End If
    End Sub

    Public Sub Search()
    Dim iPos As Integer
    'create a connection object and command object, to connect the
    Index Server
    Dim odbSearch As New
    System.Data.OleDb.OleDbConnection("Provider=""MSIDXS"";Data
    Source=""Library"";")
    Dim cmdSearch As New System.Data.OleDb.OleDbCommand()
    'assign connection to command object cmdSearch
    cmdSearch.Connection = odbSearch

    'Query to search a free text string in the catalog in the
    contents of the indexed documents in the catalog
    Dim searchText As String = btntxtSearch.Text.Replace("'",
    "''")
    cmdSearch.CommandText = "select doctitle, filename, vpath,
    rank, characterization from scope() where FREETEXT(Contents, '" &
    searchText & "') order by rank desc"
    odbSearch.Open()

    Try
    'execute search query
    Dim rdrSearch As System.Data.OleDb.OleDbDataReader =
    cmdSearch.ExecuteReader()
    'loop through each result and bind it to the repeater
    control
    While rdrSearch.Read()
    'Assemble the search result text and abstract
    getpagelink(rdrSearch(0).ToString(),
    rdrSearch(2).ToString(), rdrSearch(4).ToString())
    End While
    Catch ex As Exception
    lbl.Text = "Search Error: " & ex.Message & "<br>"
    End Try

    odbSearch.Close()

    ' Populate the repeater control with the Items DataSet
    Dim objPds As New PagedDataSource()
    objPds.DataSource = values

    ' Indicate that the data should be paged
    objPds.AllowPaging = True

    ' Set the number of items you wish to display per page
    objPds.PageSize = 50

    ' Set the PagedDataSource's current page
    objPds.CurrentPageIndex = CurrentPage

    'Display a summary for the current search
    resultSummary.Text = ((("Your search for <b>" &
    btntxtSearch.Text & "</b> Returned ") & (cnt - 1) & " Results. " &
    "<br>Page: ") & (CurrentPage + 1).ToString() & " of ") &
    objPds.PageCount.ToString()

    ' Disable Prev or Next buttons if necessary
    cmdPrev.Enabled = Not objPds.IsFirstPage
    cmdNext.Enabled = Not objPds.IsLastPage

    repSearchResults.DataSource = objPds
    repSearchResults.DataBind()
    End Sub
    End Class
     
    Mel, Mar 25, 2010
    #8
  9. Mel

    Mel Guest

    On Mar 25, 2:08 pm, Mel <> wrote:
    > On Mar 25, 9:48 am, "Patrice" <http://scribe-en.blogspot.com/> wrote:
    >
    > > > I tried just "path" instead of "vpath" (which is virtual path) and I
    > > > believe that will work.

    >
    > > Based on the name vpath would be likely some kind of virtual directory
    > > (perhaps when you index content on another server using a share ?). So path
    > > should do it if you are on the same server...

    >
    > > --
    > > Patrice

    >
    > Got it.  Almost done, however, when I release my new awesome search
    > page to the web server the Next Page linkbutton doesn't work; it
    > returns an error listed below.  The code does work on my local
    > computer while debugging but does not work on the web server.  Ever
    > had this problem?  I don't use the ViewState much so I may need to
    > read up on that....  Just thought I would post in case you have ever
    > had this same issue.
    >
    > Server Error in '/' Application:  Index was out of range. Must be non-
    > negative and less than the size of the collection.
    > Parameter name: index
    >
    > Example Code:
    > Public Class Library
    >     Inherits System.Web.UI.Page
    >     Protected values As New ArrayList()
    >     Public cnt As Integer
    >
    >     Public Property CurrentPage() As Integer
    >         Get
    >             Dim o As Object = Me.ViewState("_CurrentPage")
    >             ' look for current page in ViewState
    >             If o Is Nothing Then
    >                 Return 0
    >             Else
    >                 ' default to showing the first page
    >                 Return CInt(o)
    >             End If
    >         End Get
    >
    >         Set(ByVal value As Integer)
    >             Me.ViewState("_CurrentPage") = value
    >         End Set
    >     End Property
    >
    >     Protected Sub cmdNext_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles cmdNext.Click
    >         ' Set viewstate variable to the next page
    >         CurrentPage += 1
    >         ' Reload control
    >         btnSearch_Click(sender, e)
    >     End Sub
    >
    >     'Execute the search
    >     Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As
    > System.EventArgs) Handles btnSearch.Click
    >         ''Reset to page 1 as a new search is performed
    >         If sender.text.ToString = "search" Then
    >             CurrentPage = 0
    >         End If
    >
    >         ' Show Prev or Next buttons upon searching
    >         cmdPrev.Visible = True
    >         cmdNext.Visible = True
    >
    >         cnt = 1
    >         If btntxtSearch.Text.Trim() = "" Then
    >             btnClear_Click(sender, e)
    >         Else
    >             lbl.Text = ""
    >             Search()
    >         End If
    >     End Sub
    >
    >     Public Sub Search()
    >         Dim iPos As Integer
    >         'create a connection object and command object, to connect the
    > Index Server
    >         Dim odbSearch As New
    > System.Data.OleDb.OleDbConnection("Provider=""MSIDXS"";Data
    > Source=""Library"";")
    >         Dim cmdSearch As New System.Data.OleDb.OleDbCommand()
    >         'assign connection to command object cmdSearch
    >         cmdSearch.Connection = odbSearch
    >
    >         'Query to search a free text string in the catalog in the
    > contents of the indexed documents in the catalog
    >         Dim searchText As String = btntxtSearch.Text.Replace("'",
    > "''")
    >         cmdSearch.CommandText = "select doctitle, filename, vpath,
    > rank, characterization from scope() where FREETEXT(Contents, '" &
    > searchText & "') order by rank desc"
    >         odbSearch.Open()
    >
    >         Try
    >             'execute search query
    >             Dim rdrSearch As System.Data.OleDb.OleDbDataReader =
    > cmdSearch.ExecuteReader()
    >             'loop through each result and bind it to the repeater
    > control
    >             While rdrSearch.Read()
    >                 'Assemble the search result text and abstract
    >                 getpagelink(rdrSearch(0).ToString(),
    > rdrSearch(2).ToString(), rdrSearch(4).ToString())
    >             End While
    >         Catch ex As Exception
    >             lbl.Text = "Search Error: " & ex.Message & "<br>"
    >         End Try
    >
    >         odbSearch.Close()
    >
    >         ' Populate the repeater control with the Items DataSet
    >         Dim objPds As New PagedDataSource()
    >         objPds.DataSource = values
    >
    >         ' Indicate that the data should be paged
    >         objPds.AllowPaging = True
    >
    >         ' Set the number of items you wish to display per page
    >         objPds.PageSize = 50
    >
    >         ' Set the PagedDataSource's current page
    >         objPds.CurrentPageIndex = CurrentPage
    >
    >         'Display a summary for the current search
    >         resultSummary.Text = ((("Your search for <b>" &
    > btntxtSearch.Text & "</b> Returned ") & (cnt - 1) & " Results. " &
    > "<br>Page: ") & (CurrentPage + 1).ToString() & " of ") &
    > objPds.PageCount.ToString()
    >
    >         ' Disable Prev or Next buttons if necessary
    >         cmdPrev.Enabled = Not objPds.IsFirstPage
    >         cmdNext.Enabled = Not objPds.IsLastPage
    >
    >         repSearchResults.DataSource = objPds
    >         repSearchResults.DataBind()
    >     End Sub
    > End Class


    Nevermind I fixed it. Had a problem in my aspx page. Thanks for all
    of your help! You rock!
     
    Mel, Mar 25, 2010
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris K.
    Replies:
    3
    Views:
    745
    Chris K.
    Jun 8, 2008
  2. cindy
    Replies:
    0
    Views:
    507
    cindy
    Aug 14, 2009
  3. Abby Lee
    Replies:
    5
    Views:
    443
    Abby Lee
    Aug 2, 2004
  4. Jack
    Replies:
    8
    Views:
    296
  5. manish
    Replies:
    5
    Views:
    173
    Bart Van der Donck
    Nov 8, 2008
Loading...

Share This Page