You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by stockii <st...@googlemail.com> on 2011/09/14 15:36:42 UTC

math with date and modulo

Hello.

i am fighting with the FunctionQuery of Solr. 

I try to get a diff of today and an dateField. from this diff, i want do a
modulo from another field with values of 1,3,6,12

in a function somthing like this. ( i know that some functions are not
available in solr)

q={!func}$v2=0&v1=(NOW - $var)&v2=modulo($v1,interval)

OR 

(DIFF(Month of Today - Month of Search) MOD interval) = 0

can anybody give me some tipps ? 

-----
------------------------------- System ----------------------------------------

One Server, 12 GB RAM, 2 Solr Instances, 8 Cores, 
1 Core with 45 Million Documents other Cores < 200.000

- Solr1 for Search-Requests - commit every Minute  - 5GB Xmx
- Solr2 for Update-Request  - delta every Minute - 4GB Xmx
--
View this message in context: http://lucene.472066.n3.nabble.com/math-with-date-and-modulo-tp3335800p3335800.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: math with date and modulo

Posted by stockii <st...@googlemail.com>.
okay, thanks a lot.

I thought, that isnt possible to get the month in my case =(  i will try out
another way.

-----
------------------------------- System ----------------------------------------

One Server, 12 GB RAM, 2 Solr Instances, 8 Cores, 
1 Core with 45 Million Documents other Cores < 200.000

- Solr1 for Search-Requests - commit every Minute  - 5GB Xmx
- Solr2 for Update-Request  - delta every Minute - 4GB Xmx
--
View this message in context: http://lucene.472066.n3.nabble.com/math-with-date-and-modulo-tp3335800p3338207.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: math with date and modulo

Posted by Chris Hostetter <ho...@fucit.org>.
: I try to get a diff of today and an dateField. from this diff, i want do a
: modulo from another field with values of 1,3,6,12
	...
: (DIFF(Month of Today - Month of Search) MOD interval) = 0

a) it looks like modulus was never implemneted as a function ... probably 
overlooked before it has not java.lang.Math.* static? ... please file a 
bug, it should be fairly trivial to add.

b) even with a mod(a,b) function, i'm not sure that you could do whta it 
seems like you want to do -- the ms() function will easily let you conpute 
the number of milliseconds between two date field, but there's no fuction 
that will give you the numeric value for the month of year (or day of 
month, or hour of day, etc...) for a date field ... even if there was, i 
don't think your calculation would work when the current month is "before" 
the month indexed in the date field.


If i understand your goal, you are probably better off indexing the month 
as it's own field (either numericly or just as a simple string) and then 
computing the list of matches you care about in the client (ie: 
fq=month:(feb, may, aug, nov) )

-Hoss