Click here to Skip to main content
15,884,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
    Try
        Dim dt_Result As New DataTable
        Dim FinalTable As New DataTable
        Dim strTagSbFld As String
        strTagSbFld = GetTagSbFldSQL()
        Dim searchString As String = txtSearch.Text
        Dim query1 As String = (strTagSbFld)
        'MsgBox(query1)
        conn.Open()
        adap.SelectCommand = New SqlCommand(query1, conn)
        adap.Fill(dt_Result)
        Dim Field0, Field1, Field2, Field3, Field4, Field5 As String


        Field0 = dt_Result.Columns(0).Caption
        Field1 = dt_Result.Columns(1).Caption
        Field2 = dt_Result.Columns(2).Caption
        Field3 = dt_Result.Columns(3).Caption
        Field4 = dt_Result.Columns(4).Caption
        Field5 = dt_Result.Columns(5).Caption

        ' Specify the location where the index files are stored
        Dim indexFileLocation As String = "C:\Users\Shahrukh\Documents\Visual Studio 2012\Projects\Simple search1\Simple search1\New folder"
        Dim dir As Lucene.Net.Store.Directory = Lucene.Net.Store.FSDirectory.GetDirectory(indexFileLocation)

        ' specify the search fields, lucene search in multiple fields
        Dim searchfields As String() = New String() {Field0, Field1, Field2, Field3, Field4, Field5}
        Dim indexSearcher As New IndexSearcher(dir)

        ' Making a boolean query for searching and get the searched hits
        'Dim hits = indexSearcher.Search(QueryMaker(searchString, searchfields))

        If SearchCriteria = "Title" Then
            Dim Searchresults As New List(Of SearchResultsTitle)()
            Dim hits = indexSearcher.Search(QueryMaker(searchString, searchfields))
            For i As Integer = 0 To hits.Length() - 1
                Dim result As New SearchResultsTitle()
                result.SrNo = i + 1
                result.Title = hits.Doc(i).GetField(Field0).StringValue()
                result.Accessionno = hits.Doc(i).GetField(Field2).StringValue()
                result.Location = hits.Doc(i).GetField(Field3).StringValue()
                result.Status = hits.Doc(i).GetField(Field5).StringValue()
                Searchresults.Add(result)
            Next
            indexSearcher.Close()
            'adap.Fill(Searchresults)
            dGridResults.ItemsSource = Searchresults

        conn.Close()
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub



I am using this code for it but its search in sql data not in lucene index so please help me to perform a search in lucene index .

[edit]SHOUTING removed, code block corrected, - OriginalGriff[/edit]
Posted
Updated 25-Nov-15 20:30pm
v2
Comments
OriginalGriff 26-Nov-15 2:30am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900