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 Indika Tantrigoda <in...@gmail.com> on 2012/11/07 23:28:52 UTC
Sorting by boolean function
Hi All,
I am trying to sort by a boolean function to sort the places that are open
and not open as given below
sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0)
However I keep getting an error message saying
Can't determine a Sort Order (asc or desc) in sort spec
'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0) asc',
pos=23
I assume that boolean functions can be used to sort. Is there anything
missing from the sort function ?
Thanks,
Indika
Re: Sorting by boolean function
Posted by Indika Tantrigoda <in...@gmail.com>.
Hi,
Yes, the new sort query worked!. Thank you for the quick response.
Thanks,
Indika
On 8 November 2012 04:31, Rafał Kuć <r....@solr.pl> wrote:
> Hello!
>
> Ahhh, sorry. I see now. The function query you are specifying for the
> sort is not proper. Solr doesn't understand that part:
>
> exists(start_time:[* TO 1721] AND end_time:[1721 TO *])
>
> try something like that:
>
>
> sort=if(exists(query($innerQuery)),100,0)+desc&innerQuery={!edismax}(start_time:[*+TO+1721]
> AND end_time:[1721+TO+*])
>
> However remember that exists function is only Solr 4.0.
>
> I don't have any example data with me right now, so I can't
> say if it will work for sure, but clean Solr 4.0 doesn't cry about
> errors now :)
>
> --
> Regards,
> Rafał Kuć
> Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
>
> > Thanks for the response, I did append the sort order but the result was
> the
> > same,
>
> > Can't determine a Sort Order (asc or desc) in sort spec
> > 'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0) asc',
> > pos=23
>
> > Thanks,
> > Indika
>
>
>
> > On 8 November 2012 04:02, Rafał Kuć <r....@solr.pl> wrote:
>
> >> Hello!
> >>
> >> From looking at your sort parameter it seems that you are missing the
> >> order of sorting. The function query will return a value on which
> >> Solr will sort and Solr needs to know if the documents should be
> >> sorted in descending or ascending order. Try something like that:
> >>
> >> sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO
> >> *]),100,0)+desc
> >>
> >> --
> >> Regards,
> >> Rafał Kuć
> >> Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch -
> ElasticSearch
> >>
> >> > Hi All,
> >>
> >> > I am trying to sort by a boolean function to sort the places that are
> >> open
> >> > and not open as given below
> >>
> >> > sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0)
> >>
> >> > However I keep getting an error message saying
> >> > Can't determine a Sort Order (asc or desc) in sort spec
> >> > 'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0)
> asc',
> >> > pos=23
> >>
> >> > I assume that boolean functions can be used to sort. Is there anything
> >> > missing from the sort function ?
> >>
> >> > Thanks,
> >> > Indika
> >>
> >>
>
>
Re: Sorting by boolean function
Posted by Rafał Kuć <r....@solr.pl>.
Hello!
Ahhh, sorry. I see now. The function query you are specifying for the
sort is not proper. Solr doesn't understand that part:
exists(start_time:[* TO 1721] AND end_time:[1721 TO *])
try something like that:
sort=if(exists(query($innerQuery)),100,0)+desc&innerQuery={!edismax}(start_time:[*+TO+1721]
AND end_time:[1721+TO+*])
However remember that exists function is only Solr 4.0.
I don't have any example data with me right now, so I can't
say if it will work for sure, but clean Solr 4.0 doesn't cry about
errors now :)
--
Regards,
Rafał Kuć
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
> Thanks for the response, I did append the sort order but the result was the
> same,
> Can't determine a Sort Order (asc or desc) in sort spec
> 'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0) asc',
> pos=23
> Thanks,
> Indika
> On 8 November 2012 04:02, Rafał Kuć <r....@solr.pl> wrote:
>> Hello!
>>
>> From looking at your sort parameter it seems that you are missing the
>> order of sorting. The function query will return a value on which
>> Solr will sort and Solr needs to know if the documents should be
>> sorted in descending or ascending order. Try something like that:
>>
>> sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO
>> *]),100,0)+desc
>>
>> --
>> Regards,
>> Rafał Kuć
>> Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
>>
>> > Hi All,
>>
>> > I am trying to sort by a boolean function to sort the places that are
>> open
>> > and not open as given below
>>
>> > sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0)
>>
>> > However I keep getting an error message saying
>> > Can't determine a Sort Order (asc or desc) in sort spec
>> > 'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0) asc',
>> > pos=23
>>
>> > I assume that boolean functions can be used to sort. Is there anything
>> > missing from the sort function ?
>>
>> > Thanks,
>> > Indika
>>
>>
Re: Sorting by boolean function
Posted by Indika Tantrigoda <in...@gmail.com>.
Thanks for the response, I did append the sort order but the result was the
same,
Can't determine a Sort Order (asc or desc) in sort spec
'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0) asc',
pos=23
Thanks,
Indika
On 8 November 2012 04:02, Rafał Kuć <r....@solr.pl> wrote:
> Hello!
>
> From looking at your sort parameter it seems that you are missing the
> order of sorting. The function query will return a value on which
> Solr will sort and Solr needs to know if the documents should be
> sorted in descending or ascending order. Try something like that:
>
> sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO
> *]),100,0)+desc
>
> --
> Regards,
> Rafał Kuć
> Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
>
> > Hi All,
>
> > I am trying to sort by a boolean function to sort the places that are
> open
> > and not open as given below
>
> > sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0)
>
> > However I keep getting an error message saying
> > Can't determine a Sort Order (asc or desc) in sort spec
> > 'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0) asc',
> > pos=23
>
> > I assume that boolean functions can be used to sort. Is there anything
> > missing from the sort function ?
>
> > Thanks,
> > Indika
>
>
Re: Sorting by boolean function
Posted by Rafał Kuć <r....@solr.pl>.
Hello!
From looking at your sort parameter it seems that you are missing the
order of sorting. The function query will return a value on which
Solr will sort and Solr needs to know if the documents should be
sorted in descending or ascending order. Try something like that:
sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO
*]),100,0)+desc
--
Regards,
Rafał Kuć
Sematext :: http://sematext.com/ :: Solr - Lucene - Nutch - ElasticSearch
> Hi All,
> I am trying to sort by a boolean function to sort the places that are open
> and not open as given below
> sort=if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0)
> However I keep getting an error message saying
> Can't determine a Sort Order (asc or desc) in sort spec
> 'if(exists(start_time:[* TO 1721] AND end_time:[1721 TO *]),100,0) asc',
> pos=23
> I assume that boolean functions can be used to sort. Is there anything
> missing from the sort function ?
> Thanks,
> Indika