Hello,

Would it work if you had two facet.query clauses? One with
availabilities:[NOW TO NOW] and one with the same clause negated?

I'm not sure if you need the actual result of the query. If not, maybe it's
simpler to run two queries (one with the clause, one with the clause
negated) and return rows=0 and just get the document count.

Best regards,
Radu
--
Elasticsearch/OpenSearch & Solr Consulting, Production Support & Training
Sematext Cloud - Full Stack Observability
http://sematext.com/


On Fri, Jun 17, 2022 at 4:19 PM <s...@indb.fr> wrote:

> Hi all,
>
> On Solr 8.6, I have a multivalued field of dateRange type which contains an
> availability table.
>
> <field name="availabilities" docValues="false" type="dateRange"
> multiValued="true" indexed="true" required="false" stored="true"/>
> "availabilities": [
>   "[2021-12-22T00:00:00Z TO 2022-01-02T23:59:59Z]",
>   "[2022-01-20T00:00:00Z TO 2022-02-02T23:59:59Z]",
>   "[2022-02-10T00:00:00Z TO 2022-02-21T23:59:59Z]"
> ]
>
> With a facet, I want to be able to select the available and/or unavailable
> people. The Solr query is as follows and works well.
>
> http://localhost:8985/solr/rby/select?facet=on&facet.query={!key=
> "FQ4@Availa
> ble now" ex=tag_availabilities}availabilities:[NOW TO
> NOW]&fl=id,availabilities&fq={!tag=tag_availabilities}availabilities:([NOW
> TO NOW])&q=*:*&rows=10&wt=json
>
> For the unavailable people query, it does not work when I exclude NOW with
> {} like this.
>
> http://localhost:8985/solr/rby/select?facet=on&facet.query={!key=
> "FQ4@Unavai
> lable" ex=tag_availabilities}availabilities:{NOW TO
> NOW}&fl=id,availabilities&fq={!tag=tag_availabilities}availabilities:({NOW
> TO NOW})&q=*:*&rows=10&wt=json
>
> Solr answers with the following error:
>
> "msg": "Wrong order: 2021-12-30T16:18:06.304 TO 2021-12-30T16:18:06.302",
>
> I found a workaround with - before field but now I can't combine the two
> filters of the facet with an OR.
>
> http://localhost:8985/solr/rby/select?facet=on&facet.query={!key=
> "FQ4@Unavai
> lable" ex=tag_availabilities}-availabilities:[NOW TO
> NOW]&fl=id,availabilities&fq={!tag=tag_availabilities}-availabilities:([NOW
> TO NOW])&q=*:*&rows=1000&wt=json
>
> Thanks for your help
>
>
>

Reply via email to