You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-users@xml.apache.org by Wojtek <vi...@gazeta.pl> on 2004/03/30 21:31:20 UTC

Index pattern

Hello,
I'd like to improve my database and use some indexes, but I have doubts.
File in collection looks like this:
<user login=wojtek>
        <url>my_url</url>
        ...
</user>

I want to make xpath query:
/user[@login='wojtek']/url

My question is how to write index pattern to make processing of above query
most efficient?
Is this correct:  ...-p user@login/wojtek  ?

Greetings,
Wojtek



Re: Index pattern

Posted by Vadim Gritsenko <va...@reverycodes.com>.
See also:
  
http://cvs.apache.org/viewcvs.cgi/xml-xindice/java/src/org/apache/xindice/core/indexer/Indexer.java?annotate=1.6

Javadoc for method getPattern(), lines 63-76. It lists supported pattern 
types. Also note, that there are two types of indexes - Name and Value. 
First one is good for tests on presense of element / attribute, second 
one - for tests on values of the element / attribute.

Vadim


Vadim Gritsenko wrote:

> Wojtek wrote:
>
>> ----- Original Message ----- From: "Vadim Gritsenko" 
>> <va...@reverycodes.com>
>>  
>>
>>> No; more like ... -p user@login , so you will be able to find any user
>>> by his login quickly.
>>>   
>>
>>
>> Sorry, I'd made a mistake. I thought about pattern:   ...-p 
>> user@login/url
>> maybe ...-p user[@login]/url    is correct? I am afraid I expect too 
>> much :)
>>  
>>
>
> You don't need "url" part - except the case when you have lots of 
> users with same username but only some of them have "url'. In this 
> artificial example, you would create two indexes: first index on 
> "user@login", so you can find users by login quickly, and second on 
> "url" element, to filter out users who do not have url element. Hope 
> you got the point - you can have an index for each predicate you want 
> to speed up.
>
> Vadim



Re: Index pattern

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Wojtek wrote:

>----- Original Message ----- 
>From: "Vadim Gritsenko" <va...@reverycodes.com>
>To: <xi...@xml.apache.org>
>Sent: Wednesday, March 31, 2004 11:02 PM
>Subject: Re: Index pattern
>
>
>  
>
>>You don't need "url" part - except the case when you have lots of users 
>>with same username but only some of them have "url'. In this artificial 
>>example, you would create two indexes: first index on "user@login", so 
>>you can find users by login quickly, and second on "url" element, to 
>>filter out users who do not have url element. Hope you got the point - 
>>you can have an index for each predicate you want to speed up.
>>
>>    
>>
>So I should use two indexes: 
>-p user@login
>-p url
>I hope I got the point. Thanks for help.
>  
>

If you have url element always (for all users) - you don't need this 
second index.
If you have only one user per login (and for query example you gave 
before) - you also do not need this second index.
In some other circumstances, you might need multiple indexes.

Vadim


Re: Index pattern

Posted by Wojtek <vi...@gazeta.pl>.
----- Original Message ----- 
From: "Vadim Gritsenko" <va...@reverycodes.com>
To: <xi...@xml.apache.org>
Sent: Wednesday, March 31, 2004 11:02 PM
Subject: Re: Index pattern


> You don't need "url" part - except the case when you have lots of users 
> with same username but only some of them have "url'. In this artificial 
> example, you would create two indexes: first index on "user@login", so 
> you can find users by login quickly, and second on "url" element, to 
> filter out users who do not have url element. Hope you got the point - 
> you can have an index for each predicate you want to speed up.
> 
So I should use two indexes: 
-p user@login
-p url
I hope I got the point. Thanks for help.

Greetings,
Wojtek



Re: Index pattern

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Wojtek wrote:

>----- Original Message ----- 
>From: "Vadim Gritsenko" <va...@reverycodes.com>
>  
>
>>No; more like ... -p user@login , so you will be able to find any user
>>by his login quickly.
>>    
>>
>
>Sorry, I'd made a mistake. I thought about pattern:   ...-p user@login/url
>maybe ...-p user[@login]/url    is correct? I am afraid I expect too much :)
>  
>

You don't need "url" part - except the case when you have lots of users 
with same username but only some of them have "url'. In this artificial 
example, you would create two indexes: first index on "user@login", so 
you can find users by login quickly, and second on "url" element, to 
filter out users who do not have url element. Hope you got the point - 
you can have an index for each predicate you want to speed up.

Vadim


Re: Index pattern

Posted by Andy Armstrong <an...@tagish.com>.
Wojtek wrote:
> Sorry, I'd made a mistake. I thought about pattern:   ...-p user@login/url
> maybe ...-p user[@login]/url    is correct? I am afraid I expect too much :)

Why do you need the /url bit?

-- 
Andy Armstrong, Tagish


Re: Index pattern

Posted by Wojtek <vi...@gazeta.pl>.
----- Original Message ----- 
From: "Vadim Gritsenko" <va...@reverycodes.com>
To: <xi...@xml.apache.org>
Sent: Wednesday, March 31, 2004 12:04 AM
Subject: Re: Index pattern


> Wojtek wrote:
>
> >Hello,
> >I'd like to improve my database and use some indexes, but I have doubts.
> >File in collection looks like this:
> ><user login=wojtek>
> >        <url>my_url</url>
> >        ...
> ></user>
> >
> >I want to make xpath query:
> >/user[@login='wojtek']/url
> >
> >My question is how to write index pattern to make processing of above
query
> >most efficient?
> >Is this correct:  ...-p user@login/wojtek  ?
> >
> >
>
> No; more like ... -p user@login , so you will be able to find any user
> by his login quickly.
>

Sorry, I'd made a mistake. I thought about pattern:   ...-p user@login/url
maybe ...-p user[@login]/url    is correct? I am afraid I expect too much :)

Greetings,
Wojtek



Re: Index pattern

Posted by Vadim Gritsenko <va...@reverycodes.com>.
Wojtek wrote:

>Hello,
>I'd like to improve my database and use some indexes, but I have doubts.
>File in collection looks like this:
><user login=wojtek>
>        <url>my_url</url>
>        ...
></user>
>
>I want to make xpath query:
>/user[@login='wojtek']/url
>
>My question is how to write index pattern to make processing of above query
>most efficient?
>Is this correct:  ...-p user@login/wojtek  ?
>  
>

No; more like ... -p user@login , so you will be able to find any user 
by his login quickly.

Vadim