lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Kabashnyuk" <ksmml...@gmail.com>
Subject Re: Tree search
Date Thu, 07 Aug 2008 14:36:51 GMT
Thanks for you reply Glen

But I saw this solution before.

And as  I said before, moving  is very often operation and storing
full path can cost additional unwanted operations and therefore
it's not a desirable solution.

Sergey Kabashnyuk
eXo Platform SAS

> There are a number of ways to do this. Here is one:
> Lose the parentid field (unless you have other reasons to keep it).
> Add a field fullName, and a field called depth :
>
> doc1
> fullName: state
> depth: 0
>
> doc2
> fullName: state/department
> depth:1
>
> doc3
> fullName: state/department/Boston
> depth: 2
>
> doc4
> fullName: state/department/Opera
> depth: 2
>
> doc4
> fullName: state/Chicago
> depth: 1
>
> doc6
> fullName: state/department/Opera/November
> depth: 3
>
>> 1. Same path, for example: /state/department/Boston – return doc3
> query: fullName:+/state/department/Boston
>
>> 2. Child of the path,  for example: /state/department – return doc3,doc4
> query: fullName:+/state/department depth:+"1"
>
>> 3. All childs of the path for example: /state/department - return  
>> doc3,doc4,doc6
> query: fullName:+/state/department/
>
> Is this what you need?
> Depending on your use cases, there may be better ways of implementing  
> this.
>
> As this is not a relational db, we are not concerned (hopefully) with
> the replicated information in the fullName field.
>
> thanks,
>
> Glen
>
> 2008/8/7 Sergey Kabashnyuk <ksmmlist@gmail.com>:
>> Hello
>> I have  such  document   structure
>> doc1
>>     id       - 1
>>     parentid - 0
>>     name  -    state
>> doc2
>>     id       - 2
>>     parentid - 1
>>     name     - department
>> doc3
>>     id       - 3
>>     parentid - 2
>>     name     – Boston
>> doc4
>>     id       - 4
>>     parentid - 2
>>     name     – Opera
>> doc5
>>     id       – 5
>>     parentid – 1
>>     name     - Chicago
>> doc6
>>     id       - 6
>>     parentid - 4
>>     name     – November
>>
>> All document a linked by parentid = id – of parent document.
>> By this link can be retrieved the full path of document,
>> for example:
>> doc3-/state/department/Boston
>> Doc5 - /state/Chicago
>>
>>
>> I want to implement search by path
>> 1. Same path, for example: /state/department/Boston – return doc3
>> 2. Child of the path,  for example: /state/department – return doc3,doc4
>> 3. All childs of the path for example: /state/department - return
>> doc3,doc4,doc6
>>
>> I need to advice how the best way it can be implemented?
>>
>> Moving  is very often operation and storing full path can cost with
>> additional unwanted operations and therefore it's not a desirable  
>> solution
>>
>> Sergey Kabashnyuk
>> eXo Platform SAS
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
>
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message