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 Chantal Ackermann <ch...@btelligent.de> on 2010/07/09 11:44:48 UTC

Sort by Day - Use of DateMathParser in Function Query?

Dear all,

this is not a new problem, I just wanted to check whether with 1.4 there
might have been changes that allow a different approach.

In my query, I retrieve results that have a date field. I have to sort
the result by day only, then by a different string field. The time of
that date shall not be used for sorting.
I cannot filter the results on a certain date (day).

This thread confirms my first thought that I need another field in the
index:
http://search.lucidimagination.com/search/document/422dc30e0a222c28/sorting_dates_with_reduced_precision#46566037750d7b5

However, is it possible to use the DateMathParser somehow in the
function queries?
If it's not yet possible - why not:
(a) is there are great risk that the performance would be bad? Or some
other reason that discourages this solution.
(b) simple not implemented

In case of (b), I might try to implement it.

Thanks!
Chantal



Re: Sort by Day - Use of DateMathParser in Function Query?

Posted by Chris Hostetter <ho...@fucit.org>.
: The idea of a default date type came while reading this on
	...
: Arguments may be numerically indexed date fields such as TrieDate (the
: default in 1.4), or date math (examples in SolrQuerySyntax) based on a
: constant date or NOW. 

ahh.. yeah, that wording was missleading.  i've fixed it




-Hoss


Re: Sort by Day - Use of DateMathParser in Function Query?

Posted by Chantal Ackermann <ch...@btelligent.de>.
Hi Hoss,

> ...somewhere you got confused, or missunderstood something.  There is no 
> "default" date field in Solr, there are only recomendations and examples 
> provided in the example schema.xml -- in Solr 1.4.1 *and* in Solr 1.4 the 
> recommended field for dealing with dates is "solr.TrieDateField"
> 

The idea of a default date type came while reading this on
http://wiki.apache.org/solr/FunctionQuery:

"""
Arguments may be numerically indexed date fields such as TrieDate (the
default in 1.4), or date math (examples in SolrQuerySyntax) based on a
constant date or NOW. 
"""

And now that I revisited that sentence, I see that it answers my
question on whether I can use date math in those queries.
Sorry for not reading more thoroughly...


> As noted in the FunctionQuery wiki page you mentioned, the ms() function 
> does not work with "solr.DateField".  
> 
> (most likely your schema.xml originally started from the example in SOlr 
> 1.3 or earlier ... *OR* ... you needed the 
> sortMissingLast/sortMissingFirst functionality that DateField supports but 
> TrieDateField does not.  the 1.4 example schema.xml explains the 
> differences)

Actually, right now, I don't need sortMissingLast because the date is
required for all documents. It is good that you mention it, though. I
will keep it in mind when considering changing a field to TrieDate.

Thanks!
Chantal




Re: Sort by Day - Use of DateMathParser in Function Query?

Posted by Chris Hostetter <ho...@fucit.org>.
: In https://issues.apache.org/jira/browse/SOLR-1297,
: Grant writes:
: """
: Note, there is a temporary workaround for this: (main query)^0
: func(...) 
: """
: 
: Is that workaround an option for my use case?

that would in fact be a workarround for sorting by function where the 
function uses "ms" to get hte milliseconds of a rounded date field -- 
however...

: > I am using 1.4.1, the date field is configured like this:
: > <fieldType name="date" class="solr.DateField" sortMissingLast="true"
: > omitNorms="true"/>
: > 
: > (The schema has been created using the schema file from 1.4.0, and I
: > haven't changed anything when upgrading to 1.4.1. TrieDate is said to be
: > the default in 1.4, so I would expect this date field to have that
: > type?)

...somewhere you got confused, or missunderstood something.  There is no 
"default" date field in Solr, there are only recomendations and examples 
provided in the example schema.xml -- in Solr 1.4.1 *and* in Solr 1.4 the 
recommended field for dealing with dates is "solr.TrieDateField"

As noted in the FunctionQuery wiki page you mentioned, the ms() function 
does not work with "solr.DateField".  

(most likely your schema.xml originally started from the example in SOlr 
1.3 or earlier ... *OR* ... you needed the 
sortMissingLast/sortMissingFirst functionality that DateField supports but 
TrieDateField does not.  the 1.4 example schema.xml explains the 
differences)


-Hoss


Re: Sort by Day - Use of DateMathParser in Function Query?

Posted by Chantal Ackermann <ch...@btelligent.de>.
Sorry for the pollution. Sorting by function will only be possible with
1.5.

In https://issues.apache.org/jira/browse/SOLR-1297,
Grant writes:
"""
Note, there is a temporary workaround for this: (main query)^0
func(...) 
"""

Is that workaround an option for my use case?

Thanks,
Chantal

On Fri, 2010-07-09 at 12:08 +0200, Chantal Ackermann wrote:
> [P.S. to my first post]
> 
> Further contemplating http://wiki.apache.org/solr/FunctionQuery.
> 
> I am using 1.4.1, the date field is configured like this:
> <fieldType name="date" class="solr.DateField" sortMissingLast="true"
> omitNorms="true"/>
> 
> (The schema has been created using the schema file from 1.4.0, and I
> haven't changed anything when upgrading to 1.4.1. TrieDate is said to be
> the default in 1.4, so I would expect this date field to have that
> type?)
> 
> On the wiki page, the following example is listed:
> Example: ms(NOW/DAY)
> Could I do that same thing with my own date?
> ms(start_date/DAY)
> 
> I tried that query:
> http://192.168.2.40:8080/solr/epg/select?qt=dismax&fl=start_date,title&sort=ms%28start_date/DAY%29%20asc,title%20asc
> 
> (search for all *:* configured in solrconfig.xml for dismax)
> 
> I get the following error message back:
> """
> message can not sort on undefined field: ms(start_date/DAY)
> 
> description The request sent by the client was syntactically incorrect
> (can not sort on undefined field: ms(start_date/DAY)).
> """
> 
> I am a complete newbie when it comes to function queries.
> 
> Thanks for any suggestions!
> Chantal
> 
> On Fri, 2010-07-09 at 11:44 +0200, Chantal Ackermann wrote:
> > Dear all,
> > 
> > this is not a new problem, I just wanted to check whether with 1.4 there
> > might have been changes that allow a different approach.
> > 
> > In my query, I retrieve results that have a date field. I have to sort
> > the result by day only, then by a different string field. The time of
> > that date shall not be used for sorting.
> > I cannot filter the results on a certain date (day).
> > 
> > This thread confirms my first thought that I need another field in the
> > index:
> > http://search.lucidimagination.com/search/document/422dc30e0a222c28/sorting_dates_with_reduced_precision#46566037750d7b5
> > 
> > However, is it possible to use the DateMathParser somehow in the
> > function queries?
> > If it's not yet possible - why not:
> > (a) is there are great risk that the performance would be bad? Or some
> > other reason that discourages this solution.
> > (b) simple not implemented
> > 
> > In case of (b), I might try to implement it.
> > 
> > Thanks!
> > Chantal
> > 
> 



Sort by Day - Use of DateMathParser in Function Query?

Posted by Chantal Ackermann <ch...@btelligent.de>.
[P.S. to my first post]

Further contemplating http://wiki.apache.org/solr/FunctionQuery.

I am using 1.4.1, the date field is configured like this:
<fieldType name="date" class="solr.DateField" sortMissingLast="true"
omitNorms="true"/>

(The schema has been created using the schema file from 1.4.0, and I
haven't changed anything when upgrading to 1.4.1. TrieDate is said to be
the default in 1.4, so I would expect this date field to have that
type?)

On the wiki page, the following example is listed:
Example: ms(NOW/DAY)
Could I do that same thing with my own date?
ms(start_date/DAY)

I tried that query:
http://192.168.2.40:8080/solr/epg/select?qt=dismax&fl=start_date,title&sort=ms%28start_date/DAY%29%20asc,title%20asc

(search for all *:* configured in solrconfig.xml for dismax)

I get the following error message back:
"""
message can not sort on undefined field: ms(start_date/DAY)

description The request sent by the client was syntactically incorrect
(can not sort on undefined field: ms(start_date/DAY)).
"""

I am a complete newbie when it comes to function queries.

Thanks for any suggestions!
Chantal

On Fri, 2010-07-09 at 11:44 +0200, Chantal Ackermann wrote:
> Dear all,
> 
> this is not a new problem, I just wanted to check whether with 1.4 there
> might have been changes that allow a different approach.
> 
> In my query, I retrieve results that have a date field. I have to sort
> the result by day only, then by a different string field. The time of
> that date shall not be used for sorting.
> I cannot filter the results on a certain date (day).
> 
> This thread confirms my first thought that I need another field in the
> index:
> http://search.lucidimagination.com/search/document/422dc30e0a222c28/sorting_dates_with_reduced_precision#46566037750d7b5
> 
> However, is it possible to use the DateMathParser somehow in the
> function queries?
> If it's not yet possible - why not:
> (a) is there are great risk that the performance would be bad? Or some
> other reason that discourages this solution.
> (b) simple not implemented
> 
> In case of (b), I might try to implement it.
> 
> Thanks!
> Chantal
> 




Re: AW: Sort by Day - Use of DateMathParser in Function Query?

Posted by Chantal Ackermann <ch...@btelligent.de>.
Hi Bastian,

that is an option but it would be more flexible to sort using a function
query.
It looks like I'll have to add that field, however. At least, for as
long as using 1.4.

Thanks,
Chantal

On Fri, 2010-07-09 at 12:08 +0200, Bastian Spitzer wrote:
> Hi Chantal,
> 
> why dont you just add another Field to your Index where u put the Day only, you can sort by this filed then
> in your queries
> 
> cheers.
> 
> -----Ursprüngliche Nachricht-----
> Von: Chantal Ackermann [mailto:chantal.ackermann@btelligent.de] 
> Gesendet: Freitag, 9. Juli 2010 11:45
> An: solr-user@lucene.apache.org
> Betreff: Sort by Day - Use of DateMathParser in Function Query?
> 
> Dear all,
> 
> this is not a new problem, I just wanted to check whether with 1.4 there might have been changes that allow a different approach.
> 
> In my query, I retrieve results that have a date field. I have to sort the result by day only, then by a different string field. The time of that date shall not be used for sorting.
> I cannot filter the results on a certain date (day).
> 
> This thread confirms my first thought that I need another field in the
> index:
> http://search.lucidimagination.com/search/document/422dc30e0a222c28/sorting_dates_with_reduced_precision#46566037750d7b5
> 
> However, is it possible to use the DateMathParser somehow in the function queries?
> If it's not yet possible - why not:
> (a) is there are great risk that the performance would be bad? Or some other reason that discourages this solution.
> (b) simple not implemented
> 
> In case of (b), I might try to implement it.
> 
> Thanks!
> Chantal
> 




AW: Sort by Day - Use of DateMathParser in Function Query?

Posted by Bastian Spitzer <bs...@magix.net>.
Hi Chantal,

why dont you just add another Field to your Index where u put the Day only, you can sort by this filed then
in your queries

cheers.

-----Ursprüngliche Nachricht-----
Von: Chantal Ackermann [mailto:chantal.ackermann@btelligent.de] 
Gesendet: Freitag, 9. Juli 2010 11:45
An: solr-user@lucene.apache.org
Betreff: Sort by Day - Use of DateMathParser in Function Query?

Dear all,

this is not a new problem, I just wanted to check whether with 1.4 there might have been changes that allow a different approach.

In my query, I retrieve results that have a date field. I have to sort the result by day only, then by a different string field. The time of that date shall not be used for sorting.
I cannot filter the results on a certain date (day).

This thread confirms my first thought that I need another field in the
index:
http://search.lucidimagination.com/search/document/422dc30e0a222c28/sorting_dates_with_reduced_precision#46566037750d7b5

However, is it possible to use the DateMathParser somehow in the function queries?
If it's not yet possible - why not:
(a) is there are great risk that the performance would be bad? Or some other reason that discourages this solution.
(b) simple not implemented

In case of (b), I might try to implement it.

Thanks!
Chantal