Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gabriel Aponte 6 posts 26 karma points
    May 10, 2012 @ 21:42
    Gabriel Aponte
    0

    Umbraco Examine: how to search inside Embedded Content data type?

    I'm using the Embedded Content data type (http://farmcode.org/post/2011/01/20/Presenting-a-new-Umbraco-data-type-Embedded-Content.aspx) and I can't seem to find a way to properly use Umbraco Examine to search inside the Embedded Content data type.

    The search result object returned presents the Embedded Content type as a string with all the fields mashed together, and not in the original xml format.

    Is there a way around this so I can search individual fields inside the embedded content type?

  • Sébastien Richer 194 posts 429 karma points
    May 10, 2012 @ 22:19
    Sébastien Richer
    0

    So the Examine index is not indexing the embedded content correctly? If you have a "potato" value in a textstring in an embedded content can you search for that? Can you give an example of a query you would expect Examine to be able to pull out of the index?

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    May 10, 2012 @ 22:27
    Hendy Racher
    0

    Hi Gabriel,

    How about an event hander so that when a node is indexed, the Embedded Content value is parsed and processed into what you want stored ?

    eg.

    using umbraco.BusinessLogic;
    using Examine;

    public class IndexEmbeddedContent : ApplicationBase
    {
    public IndexEmbeddeContent()
    {
    ExamineManager.IndexProviderCollection["indexer"].GatheringNodeData +=
    new EventHandler<IndexingNodeDataEventArgs>(this.IndexType_GatehringNodeData);
    }

    private void IndexType_GatheringNodeData(object sender, IndexingNodeDataEventArgs e)
    {
      // parse embedded content field from - e.NodeId
      // save new value in a new field - e.Fields.Add("field", "value");
    }
    }

    HTH,

    Hendy

     

     

  • Gabriel Aponte 6 posts 26 karma points
    May 10, 2012 @ 22:29
    Gabriel Aponte
    0

    So, I have an embedded content type which is a list of individual strings and an option content picker for each of them. The search result object returns a string with all the fields mashed together. So in your example about "potato" I won't get any results because from what I can see the embedded content data type is recognized as a long string, something like: potato1308apple1409orange1309 and I can't search any keyword within that string.

  • Hendy Racher 861 posts 3844 karma points MVP 2x admin c-trib
    May 10, 2012 @ 22:56
    Hendy Racher
    0

    Here's another post from The Farm explaining how the uComponents MultiNodeTreePicker xml value is parsed and then space delimited for indexing.

    I guess another approach might be some sort of custom lucene indexer ? (but that sounds like more work !)

  • Gabriel Aponte 6 posts 26 karma points
    May 11, 2012 @ 16:01
    Gabriel Aponte
    0

    Hello Hendy!,.. For your first solution the only problem is that by the time the GatheringNodeDataHandler kicks in the value of my Embedded Content inside the node is already a mashed string,.. So it would be ok if I had a way to split the string, but sadly I don't have control over what the user is going to input, so it appears I need to modify how the Embedded Content type gets saved, intercept it and modify it.. Let me try your second proposition... 

    Gab.

  • Gabriel Aponte 6 posts 26 karma points
    May 11, 2012 @ 16:11
    Gabriel Aponte
    0

    ohhhh,... It seems that I don't have the commas to replace with spaces in the Embedded Content (your second suggestion). So probably I need to change the way embedded content gets saved. Or would there be another solution?

  • Gabriel Aponte 6 posts 26 karma points
    May 11, 2012 @ 17:18
    Gabriel Aponte
    0

    I think I misunderstood!... I can find the node I want from the GatheringNodeDataHandler and just ADD the content I want to the index!. (duh!). I'll try it out and get back to post my results...

    GA

  • Sébastien Richer 194 posts 429 karma points
    May 11, 2012 @ 17:34
    Sébastien Richer
    0

    Yes I think using the ID, you can get the Node from the library and simply use the real node's data to add special fields to that node's index so that it's indexed exactly the ways you want.

  • Gabriel Aponte 6 posts 26 karma points
    May 15, 2012 @ 21:38
    Gabriel Aponte
    0

    So it worked... Basically using Hendy's post and then looking for the node inside the GatheringNodeDataHandler.

    NOTE: inside your new class you should use new DynamicNode(nodeID) to access your content. umbraco.library.MacroEngines.GetNodeById() is not going to work.

    Gabriel.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies