Thanks Andy. I have been thinking along the same line as your solution, and your solution is what looks like I will have to do.
In summary, there is no Solr built-in way to achieve my need, I have to construct my document and build a query to get this working. Steve On Mon, Apr 20, 2015 at 10:57 AM, Andrew Chillrud <achill...@opentext.com> wrote: > Don't know if this is what you are looking for, but we had a similar > requirement. In our case each folder had a unique identifier associated > with it. > > When generating the Solr input document our code populated 2 fields, > parent_folder, and folder_hierarchy (multi-valued), and for a document in > the root->foo->bar folder added: > > parent_folder:<id of bar folder> > folder_hierarchy:<id of bar folder> > folder_hierarchy:<id of foo folder> > folder_hierarchy:<id of root folder> > > At search time, if you wanted to restrict your search within the folder > 'bar' we generated a filter query for either 'parent_folder:<id of bar > folder>' or 'folder_hierarchy:<id of bar folder>' depending on whether you > wanted only documents directly under the 'bar' folder (your case 3), or at > any level underneath 'bar' (your case 1). > > If your folders don't have unique identifiers then you could achieve > something similar by indexing the folder paths in string fields: > > parent_folder:root|foo|bar > folder_hierarchy:root|foo|bar > folder_hierarchy:root|foo > folder_hierarchy:root > > and generating a fq for either 'parent_folder:root|foo|bar' or > 'folder_hierarchy:root|foo|bar' > > If you didn't want to have to generate all the permutations for the > folder_hierarchy field before sending the document to Solr for indexing you > should be able to do something like: > > <fieldType name="folder_path" class="solr.TextField" > positionIncrementGap="100"> > <analyzer type="index"> > <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="|"/> > </analyzer> > <analyzer type="query"> > <tokenizer class="solr.KeywordTokenizerFactory"/> > </analyzer> > </fieldType> > > <field name="folder_parent" type="string" > indexed="true" stored="true" multiValued="false"/> > <field name="folder_hierarchy" type="folder_path" indexed="true" > stored="true" multiValued="true"/> > > <copyField source="folder_parent" dest="folder_hierarchy"/> > > In which case you could just send in the 'folder_parent' field and Solr > would generate the folder_hierarchy field. > > For cases 2 and 4 you could do something similar by adding 2 additional > fields that just index the folder names instead of the paths. > > - Andy - > > -----Original Message----- > From: Steven White [mailto:swhite4...@gmail.com] > Sent: Monday, April 20, 2015 9:49 AM > To: solr-user@lucene.apache.org > Subject: Re: Multilevel nested level support using Solr > > Re sending to see if anyone can help. Thanks > > Steve > > On Fri, Apr 17, 2015 at 12:14 PM, Steven White <swhite4...@gmail.com> > wrote: > > > Hi folks, > > > > In my DB, my records are nested in a folder base hierarchy: > > > > <Root> > > <Level_1> > > record_1 > > record_2 > > <Level_2> > > record_3 > > record_4 > > <Level_3> > > record_5 > > <Level_1> > > <Level_2> > > <Level_3> > > record_6 > > record_7 > > record_8 > > > > You got the idea. > > > > Is there anything in Solr that will let me preserve this structer and > > thus when I'm searching to tell it in which level to narrow down the > > search? I have four search levels needs: > > > > 1) Be able to search inside only level: <Root>.<Level_1>.<Level_2>.* > > (and everything under Level_2 from this path). > > > > 2) Be able to search inside a level regardless it's path: <Level_2>.* > > (no matter where <Level_2> is, i want to search on all records under > > Level_2 and everything under it's path. > > > > 3) Same as #1 but limit the search to within that level (nothing below > > its level are searched). > > > > 4) Same as #3 but limit the search to within that level (nothing below > > its level are searched). > > > > I found this: > > https://cwiki.apache.org/confluence/display/solr/Uploading+Data+with+I > > ndex+Handlers#UploadingDatawithIndexHandlers-NestedChildDocuments > > but it looks like it supports one level only and requires the whole > > two levels be updated even if 1 of the doc in the nest is updated. > > > > Thanks > > > > Steve > > >