Try our conversational search powered by Generative AI!

Indexing extra properties for Episerver Find and retrieving information from the index

Vote:
 

Hello everyone,

I am currently using an extension method to index extra properties in the index for the website I am working on. I have verified that this is being indexed correctly in the index.

I am wondering how I would filter against this and return it to an API. Currently, the only suggestion I have seen is to call the extension method again to get the information needed, but ideally, I would like to return this from the index rather than calling the logic to get the required information again.

Is there any way to get this information from the index again rather than calling the same method to work out the information?

Thanks 

#188885
Mar 06, 2018 11:43
Vote:
 

Using an extension method is the way to go. The method will not be called, instead it's translated into a filter that will be executed on the index. E.g.:

var query = this.client.UnfiedSearchFor("bananas")
    .Filter(x => x.MyExtensionMethod().Match("Monkey"))
    .GetResult();

In this case the logic in MyExtensionMethod will not be executed.

#188900
Mar 06, 2018 15:44
Vote:
 

Just to clarify even further... What you pass in the filter is an expression and not a function that will be invoked. The expression is then translated into filters that Find/Elastic understands.

#188901
Mar 06, 2018 15:46
Vote:
 

Hello Johan,

Is there a way to access the values after the find query has returned a list of the results. For example, if I have a URL indexed as an extra property, is there a way to access that and return it in an API call after the find query has returned the results?

Thanks for your example!

#188909
Mar 06, 2018 17:39
Vote:
 

What type of objects are you indexing? Why not add the URL as a property on that object then?

If you're searching for Episerver content, there is no nice way to get the value from the index since Find will only retrieve the ContentReference and then get the actual data from Episerver's IContentLoader, so then you have to call your extension method again.

If you're using UnfiedSearch there is already a metadata dictionary on UnifiedSearchHit where you can add custom data and also filter on.

#188911
Edited, Mar 06, 2018 18:02
* 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.