I've been searching the forum and Google for a while but can't seem to find an answer for a hopefully simple question...
Using umbraco.tv I've set up a search using Examine for my website. Everything is working well and the search results are showing up fine, however I can't figure out how to add a thumbnail.
The thumbnail is a media picker in umbraco with the alias "mainImage", and my ItemTemplate for the user control is below:
As you can see, it's showing the URL, name and the related tags successfully, but my custom mainImage field is causing an error: "The given key was not present in the dictionary."
I've since tried with other custom fields, including text strings, media pickers etc, but no luck.
I'm hoping it's just due to my lack of Examine experience and I've missed something really simple, but I have looked everywhere and can't find a similar question or thread.
Looks like there should be an easier way but nothing else was working for me! Feel free to contribute if anyone has a much shorter version of the above.
To cut down the amount of code you can make use of GatheringNodeData event and during indexing get the mainImage value get the media item then the actual url and inject the url into a new examine field say called imainImageUrl. That way in your repeater you can then have
You have a bit of work todo but its done during indexing time thus when you get your search results it will be more performant because you are doing the lookup for the url from the index. So one getfield call will be quicker than getting field from examine then getting media item.
Examine search results
Hi all,
I've been searching the forum and Google for a while but can't seem to find an answer for a hopefully simple question...
Using umbraco.tv I've set up a search using Examine for my website. Everything is working well and the search results are showing up fine, however I can't figure out how to add a thumbnail.
The thumbnail is a media picker in umbraco with the alias "mainImage", and my ItemTemplate for the user control is below:
As you can see, it's showing the URL, name and the related tags successfully, but my custom mainImage field is causing an error: "The given key was not present in the dictionary."
I've since tried with other custom fields, including text strings, media pickers etc, but no luck.
I'm hoping it's just due to my lack of Examine experience and I've missed something really simple, but I have looked everywhere and can't find a similar question or thread.
Thanks in advance for any help you have!
Adam.
Adam,
Can you use luke (http://luke.codeplex.com/) and take a peak in the index what do you see when you do search. Can you see that field?
Regards
Ismail
Hi Ismail,
Thanks, I couldn't find the field, turns out there was a spelling error where I was adding the field to my index. D'oh, complete fail on my part.
The only problem after that was that it would only return the image ID. I ended up writing this ugly bit of code to get the image to show up:
Looks like there should be an easier way but nothing else was working for me! Feel free to contribute if anyone has a much shorter version of the above.
Thanks again,
Adam.
Adam,
To cut down the amount of code you can make use of GatheringNodeData event and during indexing get the mainImage value get the media item then the actual url and inject the url into a new examine field say called imainImageUrl. That way in your repeater you can then have
See here about GatheringNodeData event
You have a bit of work todo but its done during indexing time thus when you get your search results it will be more performant because you are doing the lookup for the url from the index. So one getfield call will be quicker than getting field from examine then getting media item.
Regards
Ismail
is working on a reply...