Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
using Umbraco8
I have 2 Doctypes that are similarly named.
IBDeCommerceProduct IBDeCommerceProduct_Folder
My issue is that when I run the following code I get both doctypes back not the one I want
ISearcher examineSearcher = ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index) ? index.GetSearcher() : null; //restrict the search to the Content section, create our search criteria object IQuery criteria = examineSearcher.CreateQuery("content"); IBooleanOperation queryNodes = criteria.GroupedOr(new string[] { __NodeTypeAlias }, "IBD_eCommerce_Product");
How do I ensure only the exact Doctype is returned?
Hi Daniel,
Does this work for you?:
ISearcher examineSearcher = ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index) ? index.GetSearcher() : null; //restrict the search to the Content section, create our search criteria object IBooleanOperation queryNodes = examineSearcher.CreateQuery("content").NodeTypeAlias("IBD_eCommerce_Product");
This has the same issue it also returns both IBDeCommerceProduct and IBDeCommerceProduct_Folder
It seams to be treating the query as IBD_eCommerce_Product a work around I have experimented and done this and it works.
IBooleanOperation queryNodes = examineSearcher.CreateQuery("content").NodeTypeAlias("IBD_eCommerce_Product").Not().NodeTypeAlias("Folder");
I wouldnt same this was the best solution but it is fine for this instance.
Hi Daniel
You can use NodeTypeAlias() method like Erik mentioned or if you want to filter on multiple document type alias:
NodeTypeAlias()
if (ExamineManager.Instance.TryGetIndex("ExternalIndex", out var index)) { var examineSearcher = index.GetSearcher(); //restrict the search to the Content section, create our search criteria object IQuery criteria = examineSearcher.CreateQuery("content"); IBooleanOperation queryNodes = criteria.GroupedOr(new string[] { __NodeTypeAlias }, new string [] { "IBD_eCommerce_Product" }); }
You could alternatively also use the NodeTypeAlias(string[] aliases) Examine search extension from this package: https://our.umbraco.com/packages/website-utilities/search-extensions/
NodeTypeAlias(string[] aliases)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Examine get exact doc type
using Umbraco8
I have 2 Doctypes that are similarly named.
IBDeCommerceProduct IBDeCommerceProduct_Folder
My issue is that when I run the following code I get both doctypes back not the one I want
How do I ensure only the exact Doctype is returned?
Hi Daniel,
Does this work for you?:
This has the same issue it also returns both IBDeCommerceProduct and IBDeCommerceProduct_Folder
It seams to be treating the query as IBD_eCommerce_Product a work around I have experimented and done this and it works.
I wouldnt same this was the best solution but it is fine for this instance.
Hi Daniel
You can use
NodeTypeAlias()
method like Erik mentioned or if you want to filter on multiple document type alias:You could alternatively also use the
NodeTypeAlias(string[] aliases)
Examine search extension from this package: https://our.umbraco.com/packages/website-utilities/search-extensions/is working on a reply...