[Logo] Space4J - Java Persistence
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Moderation Log] Moderation Log   [Register] Register / 
[Login] Login 
indexed filtering on multiple bean properties  XML
Forum Index » General Questions
Author Message
snacht



Joined: 12/11/2009 08:46:50
Messages: 3
Offline

I have a web grid showing 250000 products.
the user can filter on of product properties
for example:
price > 30 AND
discount < 20 AND
type.contains("mx")

No problemo for sql. (even for type.contains('mx') -> oracle can create indexes on calculated values).
how about space4j?
Can I implement an index for this in space4j.
Would I have to create a separate index for each combination of bean properties?
Any help welcome.
Thanks,
Stefaan
saoj



Joined: 05/09/2008 13:26:12
Messages: 45
Offline

You can use two indexes (one for price and one for discount) or one composite index.

Check the code below that can be found here: http://s4j.mentaframework.org/posts/list/5.page

Now for the type.contains("mx"), there is no index that can index this, not even in a relational database. So you have to loop and check for each record you return.





-Sergio Oliveira Junior
snacht



Joined: 12/11/2009 08:46:50
Messages: 3
Offline

Hi thanks for the quit reply:

Now for the type.contains("mx"), there is no index that can index this,

Actually, oracle 10g can index calculated values, eg the x like '%bla%' or any other function used in a query.

Having said that, is it really necessary to iterate all values. Let's say we have an ordered index on the type property.
if a is an array of products ordered by type, and a[j] is the first value for which type.contains("mx") and a[k] is the last value for which type.contains("mx"), dont' then all
values between i and k also have type.contains("mx")?
saoj



Joined: 05/09/2008 13:26:12
Messages: 45
Offline


Hummm. If the substring lookup is fixed then perhaps you can index it. But Space4J does not support this.

Something nice to be implemented by someone. Want to give it a try?

Or if the subset returned by price and discount is relatively small you can just iterate.


-Sergio Oliveira Junior
snacht



Joined: 12/11/2009 08:46:50
Messages: 3
Offline

Thanks again,
Uhh. What I said before was actually untrue:
mxaaaaa
bbbbbbbb
zzzzzzzmx

1,3 contain mx, the middle one does not.

Want to give it a try?

maybe


Or if the subset returned by price and discount is relatively small you can just iterate.

users might only filter on type, so this would not work.


 
Forum Index » General Questions
Go to:   
Powered by JForum 2.1.8 © JForum Team