Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Prgrammaticaly initiate an index on a folder - SearchUnit - Forum

Welcome Guest Search | Active Topics | Log In | Register

#1 Posted : Thursday, August 1, 2019 10:26:00 AM
Rank: Member

Groups: Registered

Joined: 2/1/2017
Posts: 10

I am trying to initiate an index on a folder that contains all the documents using the following code which I have referenced from the documentation, is this the correct approach and is there any way to know when the index has completed?


    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim configuration As Keyoti.SearchEngine.Configuration = New Configuration
        configuration.IndexDirectory = webconfig.AppSettings("search_index_path").ToString()

        Dim documentIndex As DocumentIndex = New DocumentIndex(configuration)
            documentIndex.ImportFileSystemFolder(webconfig.AppSettings("local_document_path").ToString(), webconfig.AppSettings("virtual_document_path").ToString(), Nothing, Nothing, False)
        End Try

        '---Search Index
        Dim sa As SearchAgent = New SearchAgent("MYKEYINFO", configuration)
        Dim res As SearchResult = sa.Search("search terms", 1, 10) 'res now holds a collection of ResultItem objects

    End Sub

Many thanks

#2 Posted : Thursday, August 1, 2019 4:06:32 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,639
Location: Canada
Hi Sanj, that code runs synchronously, so the indexing will be finished when your method completes.

If this is asp.net code then that might be a problem, because if there are a lot (hundred or more) of documents it will take non trivial time and could timeout the request.

Do you know how to run code asynchronously with Task?

There is also this way to add documents asynchronously but its only for one document at a time

-your feedback is helpful to other users, thank you!

Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.