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?
Kindly help me in figuring this out. Thanks.
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.
Ok Joel, thanks for your suggestion.
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))
var result = client.Index(fd);
resultMessage += fd.Name +"- Indexed: Id - " + result.Id + ". ";
resultMessage += fd.Name +"- NotIndexed. ";
catch (Exception ex)
resultMessage += fd.Name +"- Error: " + ex.Message + ". ";
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?
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.
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.
What happens if you don't use the For method? Ie just call GetResult directly. Do you get any hits then?
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."
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.
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.