Node A -- Node B ---- Node 1 ---- Node 2 -- Node C ---- Node 3 ---- Node 4
We would like to allow the user to search at various levels in the tree. For example, if the user is searching in the "Node C" context, only return search results found in Node 3 and Node 4. If the user is searching in the "Node A" context, we would return search results for any of Node A's descendants matching the search query.
Any suggestions on the best way to do this? Is this something that can be accomplished with the Fluent API, or will we need to loop through the search results and perform the filtering after the results are returned?
I have done this on a few projects by injecting the path into the index by replacing the , in the existing path using gatheringnode event then you can filter so that the path you pass into search can be used as filter. You already have in the index field called path looks like -1,1366,1367,1375 etc so in new field call it searchablePath replace , with space so you have -1 1366 1367 1375 you can then use a start node as filter on searchablePath.
Limit Examine Search Results to Specific Nodes
Our content tree is set up as follows:
Node A
-- Node B
---- Node 1
---- Node 2
-- Node C
---- Node 3
---- Node 4
We would like to allow the user to search at various levels in the tree.
For example, if the user is searching in the "Node C" context, only return search results found in Node 3 and Node 4.
If the user is searching in the "Node A" context, we would return search results for any of Node A's descendants matching the search query.
Any suggestions on the best way to do this? Is this something that can be accomplished with the Fluent API, or will we need to loop through the search results and perform the filtering after the results are returned?
Using version 4.7.1.
Thanks.
Store the node path into index, such as node path for NodeA is /NodeA, and node path for NodeC is /NodeA/Nodec etc.
Then you can use node path of current search context to get proper nodes( Use PrefixQuery).
bparks,
I have done this on a few projects by injecting the path into the index by replacing the , in the existing path using gatheringnode event then you can filter so that the path you pass into search can be used as filter. You already have in the index field called path looks like -1,1366,1367,1375 etc so in new field call it searchablePath replace , with space so you have -1 1366 1367 1375 you can then use a start node as filter on searchablePath.
Regards
Ismail
is working on a reply...