Reputation: 418
I have the following data value for the object I am retrieving with Examine (image link for easier viewing):
__Icon: icon-shopping-basket-alt-2 color-red __IndexType: content __NodeId: 1413 __NodeTypeAlias: sale __Path: -1,1098,1410,1413 id: 1413 nodeName: Sale test 1 (active) nodeTypeAlias: Sale path: 1098 1410 1413 saleEndDate: 20151231160336000 saleStartDate: 20151026160321000 updateDate: 2015-11-18T17:03:05 writerName: Admin
The path attribute is stripped version of __Path. This was done because there were issues with starting the query with -1 and having commas as query values.
The problem I am experiencing is related with having to query a part of path, for example - retrieving the objects that contain the desired id (in a particular case just 1410).
I have executed the following query in Examine Manager from Umbraco: +nodeTypeAlias: sale +path:1468
.
The C# code example looks like this:
var queryAllSalesInDepartment = searchCriteria
.Field(Constant.Examine.AttributeFields.NodeTypeAlias, Constant.DocumentTypeAlias.Sale)
.And().Field(Constant.Examine.AttributeFields.Path, Umbraco.AssignedContentItem.Parent.Id.ToString())
.Compile();
The query yields 0 results, despite the fact that there are available values in indexes.
Am I doing the query wrong or should I reconsider formatting the path value differently?
Upvotes: 3
Views: 1088
Reputation: 3425
Yeah, the query needs to be "fuzzier" :-s You can go the (in my opinion) hard-to-read way like this: https://our.umbraco.org/forum/developers/extending-umbraco/11659-Examine-quering-path or the raw query way like this:
searchCriteria.RawQuery(@"+path:\-1*" + parentId + "*");
parentId being 1410 in your example.
Upvotes: 6