Function query looks like the nearest match to your requirement:
https://lucene.apache.org/solr/guide/7_5/function-queries.html#ms-function

You can use it in the field list too.

Regards,
   Alex.
On Mon, 12 Nov 2018 at 09:12, Hullegård, Jimi
<jimi.hulleg...@svensktnaringsliv.se> wrote:
>
> Hi,
>
> Maybe I have been working too little with Solr lately, but I'm stuck on a 
> very simple problem (in my mind), and need some help.
>
> How can I include the result of a date calculation in the field list?
>
> For example, let's say that the documents in my index contains the date field 
> 'deadline'. When constructing the query, I can add a filter query like:
>
> deadline:[* TO NOW]
>
> But if I don't want to filter on this, but instead include the "deadline 
> status" (ie past deadline) in the result, how do I achieve that?
>
> I tried:
>
> fl=*,deadline:[* TO NOW]
>
> But then solr complains with the error message "Error parsing fieldname". I 
> then tried to add an alias, as such:
>
> fl=*,pastDeadline:deadline:[* TO NOW]
>
> and that didn't result in an error, but it didn't give me the result I wanted 
> either. This resulted in this field in the result:
>
> <date name="pastDeadline">2007-11-15T11:00:00Z</date>
>
> So the pastDeadline simply contains the date value, when I expected a boolean 
> value "true".
>
> So, how can I achieve this? I would prefer not having to do the date 
> calculation outside of solr.
>
> We use Solr 6.6.4.
>
> Regards
> /Jimi
>
> Svenskt Näringsliv behandlar dina personuppgifter i enlighet med GDPR. Här 
> kan du läsa mer om vår behandling och dina rättigheter, 
> Integritetspolicy<https://www.svensktnaringsliv.se/dataskydd/integritet-och-behandling-av-personuppgifter_697219.html?utm_source=sn-email&utm_medium=email>

Reply via email to