i've dropped the above code into a controller to debug it and it works as expected so i'm guessing it's possibly something to do with how the helper is getting the typed content?
without wanting to reinvent the wheel, i'm guessing there's a more standard way to do this what with the mntp being such a useful property datatype?!
any suggestions on how to dig myself out of this one would be blardy amazing ;)
the trick is that i need the 'Name' property from the selected document to then search against...
so i need to do something inside the foreach loop to get the content based on the 'umb://document/3457a1b68ef6471fb681d4fc8f864f8b' value, then get the name property value and store that?
i'll keep going through the slides but this is a bit of a head scratcher!
public class Examine : IApplicationEventHandler
{
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
var indexer = ExamineManager.Instance.IndexProviderCollection["JobsIndexer"];
var luceneIndexer = indexer as LuceneIndexer;
if (luceneIndexer != null) luceneIndexer.DocumentWriting += OnDocumentWriting;
}
private static void OnDocumentWriting(object sender, DocumentWritingEventArgs e)
{
var skills = e.Fields["jobSkills"].Split(',');
foreach (var skill in skills)
{
e.Document.Add(new Field("skill", skill, Field.Store.YES, Field.Index.ANALYZED));
}
}
}
debugging the loop looks like this:
and if i do a search on the index i can see the values:
my thinking though is that i need the 'jobSkills' to be a comma seperated value of the skill node names e.g.
Creative, Frontend, Backend, Admin
i think i'm heading about it the right way, it's just getting the skill name rather than the 'umb://document/3457a1b68ef6471fb681d4fc8f864f8b' value thats the key?
funny you should suggest that! i woke up in the middle of the night with that very same idea floating around in my head... never go to sleep with an unresolved problem eh?!
the key was the line:
var udi = GuidUdi.Parse(skill);
i wasn't aware of 'GuidUdi.Parse()' which is far better than the string find and replace idea i was going to run with.
it's an interesting one, tbh i didn't think it would be this complex to get mntp selections into an index but this does indeed work ;)
i guess the only thing that i might try is to do the same thing but passing the umbraco helper to 'OnDocumentWriting'. the site i'm working on will have potentially thousands of nodes which means hitting up the content service with it's multiple database hits will be very slow... getting typedcontent using the helper should in theory be faster (i'll test it out).
thank you for the replies and suggestions, great to have got a working solution!
how do i add multinodetreepicker2 values to a lucene index?
ok chaps, this feels like it should be easy but it's being a pain!
how do i add multinodetreepicker2 node property values to a lucene index?!
my initial thinking was to do something like this:
i'd expect 'nodes' to be a 'IEnumerable
so i did some debugging and the property 'entries' is being returned as:
expanding that has 4 entries:
wtf?!
i've dropped the above code into a controller to debug it and it works as expected so i'm guessing it's possibly something to do with how the helper is getting the typed content?
without wanting to reinvent the wheel, i'm guessing there's a more standard way to do this what with the mntp being such a useful property datatype?!
any suggestions on how to dig myself out of this one would be blardy amazing ;)
cheers,
jake
Hi Jake,
Have look at slide 51 of this presentation https://www.slideshare.net/dawoe/the-need-for-speed-uk-fest
that is example of indexing a comma seperated string.
Dave
hi dave, thank you for taking the time to reply, really appreciate it.
i've taken a look at the suggested slide and implemented the code. the index now has a value however it's still the 'umb://document/gui' values e.g.
entry: umb://document/3457a1b68ef6471fb681d4fc8f864f8b,umb://document/4cf5cad9b391459bb4ed0e69a44dd17a,umb://document/a12f8f826b2a40d588bedb8ee46c7063,umb://document/353516f7bad144b7a6d3a618f7249005
the trick is that i need the 'Name' property from the selected document to then search against...
so i need to do something inside the foreach loop to get the content based on the 'umb://document/3457a1b68ef6471fb681d4fc8f864f8b' value, then get the name property value and store that?
i'll keep going through the slides but this is a bit of a head scratcher!
cheers,
jake
Hi Jake,
My assumption was that you you would just need the id of the selected item.
Can you post your updated code ?
dave
hi dave,
sure thing:
debugging the loop looks like this:
and if i do a search on the index i can see the values:
my thinking though is that i need the 'jobSkills' to be a comma seperated value of the skill node names e.g.
i think i'm heading about it the right way, it's just getting the skill name rather than the 'umb://document/3457a1b68ef6471fb681d4fc8f864f8b' value thats the key?
cheers,
jake
Hi Jake,
Can you try this ?
This uses the content service to get the item from UDI
dave
hi dave,
funny you should suggest that! i woke up in the middle of the night with that very same idea floating around in my head... never go to sleep with an unresolved problem eh?!
the key was the line:
i wasn't aware of 'GuidUdi.Parse()' which is far better than the string find and replace idea i was going to run with.
it's an interesting one, tbh i didn't think it would be this complex to get mntp selections into an index but this does indeed work ;)
i guess the only thing that i might try is to do the same thing but passing the umbraco helper to 'OnDocumentWriting'. the site i'm working on will have potentially thousands of nodes which means hitting up the content service with it's multiple database hits will be very slow... getting typedcontent using the helper should in theory be faster (i'll test it out).
thank you for the replies and suggestions, great to have got a working solution!
cheers,
jake
is working on a reply...