[
    {
        "id": "doc_1",
        "name": "Harpreet Chaggar",
        "_childDocuments_": [
            { "id": "child_doc_a", "number": 
22,"created_at":"2020-03-20T00:00:00Z" },
            { "id": "child_doc_b", "number": 10 
,"created_at":"2021-05-28T00:00:00Z"},
        ]
    },
    {
        "id": "doc_2",
        "name": "Hardik Deshmukh",
        "_childDocuments_": [
            { "id": "child_doc_1", "number": 
67,"created_at":"2022-03-20T00:00:00Z" },
            { "id": "child_doc_2", "number": 78 
,"created_at":"2022-05-28T00:00:00Z"},
        ]
    },
]
My objective is to make exclude query for a nested Date Data along with some 
parent conditions and to return parent document for all queries.
I am trying to fetch "id" : "doc_2", "name": "Hardik Deshmukh" by the following 
query. Note:- I need parent document in return.
q = {!parent which='(name:("Hardik" OR "Harpreet") AND 
id:"doc_1")'}-created_at:[2020-01-17T00:00:00Z TO 2021-12-17T00:00:00Z]
But I am not getting any results.
To make sure if the date query is working properly, I executed the below query.
q = -created_at:[2020-01-17T00:00:00Z TO 2021-12-17T00:00:00Z]
And it was working.
  "response":{"numFound":4,"start":0,"numFoundExact":true,"docs":[
      {
        "id":"doc_1",
        "name":["Harpreet Chaggar"],
        "_version_":1746310602768252928},
      {
        "id":"child_doc_1",
        "number":["67"],
        "created_at":"2022-03-20T00:00:00Z",
        "_version_":1746310602791321600},
      {
        "id":"child_doc_2",
        "number":["78"],
        "created_at":"2022-05-28T00:00:00Z",
        "_version_":1746310602791321600},
      {
        "id":"doc_2",
        "name":["Hardik Deshmukh"],
        "_version_":1746310602791321600}]
  }}
Field types:
For created_at
Field-Type:org.apache.solr.schema.DatePointField

For name
Field-Type:org.apache.solr.schema.TextField

And if I want to fetch "id": "doc_1", I am able to get it by executing the 
following query.
{!parent which='(name:("Hardik" OR "Harpreet") AND id:"doc_1")'} ( 
created_at:[2020-01-17T00:00:00Z TO 2021-12-17T00:00:00Z] )
It fetches desired results.
"response":{"numFound":1,"start":0,"numFoundExact":true,"docs":[
      {
        "id":"doc_1",
        "name":["Harpreet Chaggar"],
        "_version_":1746310602768252928}]
  }}

TL;DR

The below query should give "id": "doc_2", but it is not giving any result.
q = {!parent which='(name:("Hardik" OR "Harpreet") AND 
id:"doc_1")'}-created_at:[2020-01-17T00:00:00Z TO 2021-12-17T00:00:00Z]


Thanks & Regards,
Hardik Deshmukh
------------------------------------------------
Cheers Interactive
!nformation | !ntelligence | !nsightTM
------------------------------------------------
India
Millennium Business Park,
Sector 3, Building # 4,
Mahape,
Navi Mumbai - 400710
Board     : +91 22 6772 5700
Email     : hardik.deshm...@cheersin.com<mailto:hardik.deshm...@cheersin.com>
www.cheersin.com<http://www.cheersin.com/>
Please consider the environment before printing this email.

"This message is intended only for the person or entity to which it is 
addressed and may contain confidential and/or privileged information. If you 
have received this message in error, please notify the sender immediately and 
delete this message from your system. Reasonable precautions have been taken to 
ensure that this message is virus-free. However, Cheers Interactive (India) Pvt 
Ltd does not accept responsibility for any loss or damage arising from the use 
of this message or attachments".



Reply via email to