Dashboard > ApacheDS Addons > ... > Search Algorithm Discussion > Search algorithm discussion (2)
Search algorithm discussion (2)
Added by Emmanuel Lécharny, last edited by Emmanuel Lécharny on Dec 06, 2005  (view change)
Labels: 
(None)


First, here is a sample :

We have searched for all entries under dc=apache, dc=org, which has an attribute Age, which value is above 30.

We have only two entries.

We have two ways to get those entries :
 - first, we have an index on dc=apache, dc=org, which gives us all its entries, including Ersin, and we have a filter (Age > 30) that eliminate Ersin. This is a two steps algorithm : we create an enumeration, and for each element we just filter the ones which match.
 - second, we may use another index, on Age, which will give us all the entries that are above 30. We will get 4 entries, the two under dc=apache, dc=org, karasulu under dc=safehaus,dc=org and lecharny under dc=iktek, dc=com. Then a filter will eliminate the last two, because they are not under dc=apache, dc=org,

In both cases, we get an enumeration which is largest than necessary.

We have a third option :

If we construct the Age index by concatenating the DirContext into which is the entry :
entry :cn=Ersin, Age=24
DN = cn=ersin, dc=apache, dc=org
Age Index : Age=24/dc=apache,dc=org instead of Age=24 (this is a String)

Now, if we are looking for the same entries, we can ask for each entries fro the Age index, where age> 30 AND base DN = dc=apache,dc=org

We will construct a request like Age>30/dc=apache,dc=org and looking into the index. We will get only two elements, as the base DN is present only in three but with the right Age.

This is not a perfect exemple, but nowlet's imagine we have a Work attribute, which will be set to Professional for karasulu and lecharny, and to student for ersin. This will work great, and with  the following request :

Work=Professionnal in dc=com

We will get only one answer from the Work index. This String is built when we add this entry, as we know where in the tree this entry will be stored (in .dc=iktek, dc=com).

The Work index will contain all these values :

Work=Professionnal/dc=iktek,dc=com
Work=Professionnal/dc=apache,dc=org

As it's a subtree search, will visiting the branches, we will construct a new request.
We start with the request Work=Professionnal/dc=com, then with Work=Professionnal/dc=iktek,dc=com, which return one entry, and we are done.

If we do the same from the dc=org DirContext, we will have a first request on the Work Index which will not return any entry, then a second request to the subtree dc=apache,dc=org which will return 2 entries, returned by the Work index.
We are sending two requests to the Work index :
Work=Professionnal/dc=org -> return null,
Work=Professionnal/dc=apache,dc=org -> return karasulu and lecharny.

We can think of it as a primary key in a DataBase, which has multiple attributes.

Site running on a free Atlassian Confluence Open Source Project License granted to Safehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators