Try our conversational search powered by Generative AI!

Index Imagevault Files

Vote:
 

How do I index Image vault files through the Indexing Job? And once indexed can the below search method used to search through files, used to search through the imagevault items also?

SearchClient.Instance.Search<UnifiedFile>().GetFilesResult()

Kindly help me in figuring this out. Thanks.

#63292
Nov 14, 2012 14:41
Vote:
 

As far as I know ImageVault doesn't store images in EPiServer's VPP folder (although I could be wrong) and in that case you need to index them yourself using a scheduled job and/or by listening to events from the ImageVault API.

Optionally it may be possible to build a page provider that exposes IV images as pages in which case they would be indexed by the indexing job.

#63360
Nov 15, 2012 20:56
Vote:
 

Ok Joel, thanks for your suggestion.

#63374
Nov 16, 2012 12:22
Vote:
 

Hi Joel,

I have indexed the ImageVault files using the following method:

protected string Index()

{

EPiServer.Find.IClient client = Client.CreateFromConfig();

client.Conventions.ForInstancesOf<IVFileData>().ExcludeField(x => x.Album);

string resultMessage = string.Empty;foreach (IVAlbumData ad inIVDataFactory.GetChildAlbums(IVDataFactory.RootAlbumId))

{

foreach (IVFileData fd in ad.GetFiles(true))

{

try

{

var result = client.Index(fd);

if (result.Ok)

{

resultMessage += fd.Name +"- Indexed: Id - " + result.Id + ". ";

}

else

{

resultMessage += fd.Name +"- NotIndexed. ";

}

}

catch (Exception ex)

{

resultMessage += fd.Name +"- Error: " + ex.Message + ". ";

}

}

}

return resultMessage;

}

By doing so I'm able to index the files and I get the result id too. I now have the following queries:

1) Each time when I run the Index method, a unique Id is generated for the same file. Does EPiServer Find create an additional index for the same file or does it over write the existing one?

2) When I run the following query to find the ImageVault  items, I always get zero results. I have tried giving both the name of the file and also content of the file, but didn't receive any result. However, I'm able to get files stored in VPP in search results.

var result = SearchClient.Instance.Search<UnifiedFile>().For(Query).GetFilesResult();

How do I get the results to include the ImageVault files also?

#63773
Nov 29, 2012 9:57
Vote:
 

Hi,

Find won't know that you are indexing the same file and will therefor return an autogenerated ID and create new documents in the index rather than updating existing. To correct that you need to specify an ID for the files. There are a number of ways to do that, including passing the ID to the Index method. I would however recommend doing it by conventions. See the Identity headline here.

 

As for not getting any results, if you are using the exact code above, you're searching for Unified Files and IV files aren't of that type. Do you get any results if you instead search for IVFileData (.Search<IVFileData>()...)?

If so you can search over both types. See this page in the the documentation.

#63803
Nov 29, 2012 18:35
Vote:
 

Hi Joel,

Thanks for your suggestions. I tried the following 2 search formats, however both doesn't give me the ImageVault search results:

var result = client.Search<IVFileData>().For(Query).GetResult();

 

 

var result = SearchClient.Instance.Search<IVFileData>().For(Query).GetResult();

 

Kindly let me know what could be the problem with it. Thanks.

#63841
Nov 30, 2012 14:53
Vote:
 

Hi,

What happens if you don't use the For method? Ie just call GetResult directly. Do you get any hits then? 

#63919
Dec 04, 2012 20:19
Vote:
 

Hi Joel,

When I just call GetResult directly, I get the error -

Newtonsoft.Json.JsonSerializationException was unhandled by user code
  Message="Unable to find a constructor to use for type ImageStoreNET.Developer.Core.IVFileData. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute."

#63934
Dec 05, 2012 10:25
Vote:
 

That means you're actually getting results but that the indexed data can't be deserialized to IVFileData which is quite natural. You should extract certains fields/properties using the Select method instead.

With that in place the question remains why you're not getting any hits for a text query. I would use the Explore view and look at what's actually in the index.

#63944
Dec 05, 2012 12:26
Vote:
 

Hi Joel,

I was able to get search hits using the select method. So instead of returning the entrire ImageVault's IVFileData object, I now select the desired properties of IVFileData to get search hits. Thanks a lot for your inputs.

#64028
Dec 07, 2012 15:47
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.