Umbraco Examine - restricting results to a particular node
I have an index set up, which I can query with great results.
However I have a section of my site, in which I would like to include a 'Search This Section' input, which would query the index but only return results from this node, or descendant nodes.
I can create multiple separate indexs, and use the IndexParentId attribute of the IndexSet to restrict indexing to certain nodes, and build a sepaarte search control for this section of the site. This works, but it doesn't seem very elegant, and it is non trivial to add new searches to sections of the site.
Ideally I would like to be able to specify a nodeId as a paramater to my search control, and have that restrict the results, say, when specifying the criteria.
Is this possible? Or does lucene not 'know' about nodes by the time it has indexed everything?
-Itterate over each result checking for a condition (result path is within my allowed paths)
-Show only matches.
Is this the best way to tackle the issue?
If my index is potentially large, is there a more effecient way to perform the search? (E.g. adding my requirements before the search is executed, perhaps as an Examine criteria/lucene paramater). Or has lucene lost the heirachical strucutre of the site in its index?
It just seems less than ideal doing all the extra searching, for example if I am only wanting to search a node that has two children, performing the search on hundreds of nodes then doing a whole bunch of proccessing to get rid of the majority of the results...
Umbraco Examine - restricting results to a particular node
I have an index set up, which I can query with great results.
However I have a section of my site, in which I would like to include a 'Search This Section' input, which would query the index but only return results from this node, or descendant nodes.
I can create multiple separate indexs, and use the IndexParentId attribute of the IndexSet to restrict indexing to certain nodes, and build a sepaarte search control for this section of the site. This works, but it doesn't seem very elegant, and it is non trivial to add new searches to sections of the site.
Ideally I would like to be able to specify a nodeId as a paramater to my search control, and have that restrict the results, say, when specifying the criteria.
Is this possible? Or does lucene not 'know' about nodes by the time it has indexed everything?
i did this programatically:
path being
Thanks for your reply.
If I understand this correctly, you are saying:
-Complete a full search of the index
-Itterate over each result checking for a condition (result path is within my allowed paths)
-Show only matches.
Is this the best way to tackle the issue?
If my index is potentially large, is there a more effecient way to perform the search? (E.g. adding my requirements before the search is executed, perhaps as an Examine criteria/lucene paramater). Or has lucene lost the heirachical strucutre of the site in its index?
It just seems less than ideal doing all the extra searching, for example if I am only wanting to search a node that has two children, performing the search on hundreds of nodes then doing a whole bunch of proccessing to get rid of the majority of the results...
Have a look at the article I wrote on search collections with Examine - http://farmcode.org/post/2010/09/22/Searching-Multi-Node-Tree-Picker-data-(or-any-collection)-with-Examine.aspx
This way you can do the filtering at search time.
Thanks kows and slace.
I have implemented a solution similar to what kows posted, due to time pressure in this project and the fact I can reuse a great chunk of my code.
I will revisit this and have a go at the solution posted by slace if I can convince the project managers it is worth the extra time :)
is working on a reply...