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?
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?
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"); } }
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.
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...
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?
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...
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.
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.
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?
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?
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.
HTH,
Hendy
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.
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 !)
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.
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?
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
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.
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.
is working on a reply...
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.