How to get field value from Examine directly
# help-with-umbraco
r
So, I am executing my search query and I receive ISearchResults which contains the collection with ISearchResult. I have a property called Text. Using the ID I can easily load the content from Content Cache and get the Text property value from there. But is there a way to get the indexed value for a property directly from Examine? I don't want to query my cache. I have a situation where this is not performing well and would prefer to get the value from the index directly.
d
When you iterate through the results from your query, you get a set of values with it. Here is a screenshot of the interface of a single result. Any line that includes
Value
contains the values from the index https://cdn.discordapp.com/attachments/1306959458345160745/1306997970436362291/image.png?ex=6738b437&is=673762b7&hm=102074fc25cd421c225489ae479f0b889a669a80a579e0d99d305bf411857b03&
r
I love that! Will give it a try on Monday! Thanks
Have you tested how it behaves performance wise? Like, if it matters, if you call the cache to get the item and read a field or to get the field direclty from from the index. I guess you need to get the item from cache anyway just to get the URL but..
d
Unfortunately no. I always convert the results into
IPublishedContent
. I can't judge your usecase, but the content cache as a bottleneck sounds to me like a red flag
j
The values are there in a dictionary, so not converting to IPublishedContent should always be faster if you don't need any propertyvalue conversion happening. We do this often when reading simple data fra a searchresult like an id or a string, fx:
Copy code
csharp
var data = searchResult.GetValues("fieldname").FirstOrDefault();
r
Usually IPublishedContent is good. But we have PDFs and i need to pull preview text and computing that is slow so i need it from the index
9 Views