You are viewing limited content. For full access, please sign in.

Question

Question

Return Search Hits

SDK
asked on July 14, 2014

I have a script that I am writing in C# where I am trying to run an automated seach monthly to Audit for any Documetns that have been added that contail an SSN.  The script will then email out the Document IDs for all the documents in the search result.

So, I have the following code to conduct the search, but how do I pull the resluts from the search:

Laserfiche.RepositoryAccess.Search mySearch = new Search(currentSession, "SSN");

mySearch.BeginRun(true);

 

0 0

Answer

SELECTED ANSWER
replied on July 14, 2014

Now the below code is a direct extract from SDK Documentation:

 

// Instantiates a search in the repository.
LFSearch NewSearch = (LFSearch)DB.CreateSearch();
// Sets the search string.
NewSearch.Command = "Fish";
// Begins the search.
NewSearch.BeginSearch(true);
// Retrieves the search hits and lists paths of the entries in which they were found.
ILFCollection AllHits = (ILFCollection)NewSearch.GetSearchHits();
for (int i = 1; i <= AllHits.Count; i++)
{
  LFSearchHit Hit = (LFSearchHit)AllHits[i];
  ILFEntry EntryHit = (ILFEntry)Hit.Entry;
  Console.WriteLine(EntryHit.FullPath);
}

1 0

Replies

replied on July 14, 2014

ILFCollection AllHits;

AllHits = (ILFCollection)mySearch.GetSearchHits();

 

 for (i = 1; i <= AllHits.Count; i++)
                {                   

                    LFSearchHit Hit = (LFSearchHit)AllHits[i];
                    ILFEntry EntryHit = (ILFEntry)Hit.Entry;

                    int DocID = EntryHit.ID;

                }

 

Above code will get you the EntryID of each document hit. With entryID you can do anything with the entry.

1 0
replied on July 14, 2014

my code is not recognizing "GetSearchHits".  Is there a reference that I need to add?

0 0
replied on July 14, 2014

Try referencing:  Laserfiche.RepositoryAccess;

replied on July 14, 2014

I have that reference included.

Could it be:

AllHits = (ILFCollection)mySearch.GetResultsListing(serlistset);

 

where serlistset is my SearchListingSettings

0 0
replied on July 14, 2014

I am still running 8.3 is this makes a difference.

0 0
replied on July 14, 2014

No 8.3 isn't an issue.

 

What exact error are you getting? 

What LF libraries do you have defined in your code?

1 0
SELECTED ANSWER
replied on July 14, 2014

Now the below code is a direct extract from SDK Documentation:

 

// Instantiates a search in the repository.
LFSearch NewSearch = (LFSearch)DB.CreateSearch();
// Sets the search string.
NewSearch.Command = "Fish";
// Begins the search.
NewSearch.BeginSearch(true);
// Retrieves the search hits and lists paths of the entries in which they were found.
ILFCollection AllHits = (ILFCollection)NewSearch.GetSearchHits();
for (int i = 1; i <= AllHits.Count; i++)
{
  LFSearchHit Hit = (LFSearchHit)AllHits[i];
  ILFEntry EntryHit = (ILFEntry)Hit.Entry;
  Console.WriteLine(EntryHit.FullPath);
}

1 0
replied on July 14, 2014 Show version history

Do you have reference to 

LFSO83Lib;

1 0
replied on July 14, 2014

I am getting the Red Sqiggly line under GetSearchHits(); indicating that it isn't recognized.  Error below:

 

"Laserfiche.RepositoryAccess.Search' does not contain a definition for "GetSearchHits' and no extention meathos 'GetSearchHits' accepting a first argument of type 'Lasrfiche.RepositoryAccess.Search' could be found (are you missing a using directive or an assembly reference?)"

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

using LFSO83Lib;

using Laserfiche.RepositoryAccess;

 

0 0
replied on July 14, 2014

Please hover your mouse on ILFCollection and see which dll it's pointing too (see screenshot)

ILFCollection.png
1 0
replied on July 14, 2014

Try commenting out Laserfiche.RepositoryAccess;

Only keep LFSO83Lib in your references.

1 0
replied on July 14, 2014

interface LFSO83Lib.ILFCollection

 

when I did a straight copy and paste of the code you posted it is clear.  So, I will just go with that.  Thank you for you assistance.

0 0
replied on July 14, 2014

Great.

 

I believe it was the conflict between RepositoryAccess and LFSO83Lib. It was picking your ILFCollection as derived from RepositoryAccess instead of lfso83lib.

 

Don't forget to mark the answer smiley.

 

Thanks

1 0
replied on July 14, 2014

commented out  Laserfiche.RepositoryAccess; gave the same issue

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.