You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Dmitri Maziuk <dm...@gmail.com> on 2025/12/12 21:57:54 UTC
why would "{!parent}" return a child document?
Hi all,
we're still struggling here with child documents, here's my problem du
jour (solr 8.11):
in the index:
```
{
"id": "W0178E6",
"odams.identifier": "W0178E6",
"is_child": false,
...
"child_objects": [
{
"id": "W0178E6!W0178F2",
"odams.identifier": "W0178F2",
"is_child":true
},
...
```
with more children:
"id": "W0178E6!W0178EX",
"id": "W0178E6!W0178F9",
"id": "W0178E6!W0178F7",
"id": "W0178E6!W0178F3",
"id": "W0178E6!W0178F1",
"id": "W0178E6!W0178EZ",
"id": "W0178E6!W0178EY",
"id": "W0178E6!W0178EO",
"id": "W0178E6!W0178EM",
My reading of The Fine Manual @
https://solr.apache.org/guide/8_11/searching-nested-documents.html is that
`q={!parent which="*:* +is_child:false}(+odams.identifier:W0178F2)`
should return the parent: W0178E6.
What I get instead is
```
{
"responseHeader":{
"status":0,
"QTime":18,
"params":{
"q":"{!parent which=\"*:* is_child:false\"}(
odams.identifier:W0178F2)",
"debugQuery":"true"}},
"response":{"numFound":1,"start":0,"numFoundExact":true,"docs":[
{
...
"id":"W0178E6!W0178EX",
"odams.identifier":"W0178EX",
...
}]
},
"debug":{
"rawquerystring":"{!parent which=\"*:* is_child:false\"}(
odams.identifier:W0178F2)",
"querystring":"{!parent which=\"*:* is_child:false\"}(
odams.identifier:W0178F2)",
"parsedquery":"AllParentsAware(ToParentBlockJoinQuery
(+odams.identifier:W0178F2))",
"parsedquery_toString":"ToParentBlockJoinQuery
(+odams.identifier:W0178F2)",
"explain":{
"W0178E6!W0178EX":"\n0.0 = Not a match\n"},
"QParser":"BlockJoinParentQParser",
"timing":{
...
```
Any ideas why?
What does is even mean `"W0178E6!W0178EX":" 0.0 = Not a match"` with the
"W0178E6!W0178EX" document returned?
Any hints welcome, TIA
Dima
Re: why would "{!parent}" return a child document?
Posted by Chris Hostetter <ho...@fucit.org>.
: > that is *probably* not a problem with solr -- it is typically an
: > indication that the way you are crafting/sending your HTTP request/url
: > includes an "un-escaped" "+" character in the URL which Jetty/Solr are
: > (required) to interpret as an escaped " " (space) character.
: Good point, if you do it in a browser it'll automagically escape everything
: (or at least chrome seems to) but REST client-type apps may or may not.
:
: Take home lesson: don't use '+', use 'AND'.
Taht is certainly not the lesson I would encourage you to take from this
experience...
https://lucidworks.com/blog/solr-boolean-operators
-Hoss
http://www.lucidworks.com/
Re: why would "{!parent}" return a child document?
Posted by Dmitri Maziuk <dm...@gmail.com>.
On 12/18/25 13:04, Chris Hostetter wrote:
>
> : (Note that output formatter strikes again: this is wrong:
> :
> : > "q":"{!parent which=\"*:* is_child:false\"}(
> : > odams.identifier:W0178F2)",
>
> that is *probably* not a problem with solr -- it is typically an
> indication that the way you are crafting/sending your HTTP request/url
> includes an "un-escaped" "+" character in the URL which Jetty/Solr are
> (required) to interpret as an escaped " " (space) character.
>
> hossman@slate:~$ curl -sS 'http://localhost:8983/solr/gettingstarted/select?q=a+b' | grep -F '"q"'
> "q":"a b"
> hossman@slate:~$ curl -sS 'http://localhost:8983/solr/gettingstarted/select?' --form-string 'q=a+b' | grep -F '"q"'
> "q":"a+b"
> hossman@slate:~$ curl -sS 'http://localhost:8983/solr/gettingstarted/select?q=a%2Bb' | grep -F '"q"'
> "q":"a+b"
>
Good point, if you do it in a browser it'll automagically escape
everything (or at least chrome seems to) but REST client-type apps may
or may not.
Take home lesson: don't use '+', use 'AND'.
Thanks,
Dima
Re: why would "{!parent}" return a child document?
Posted by Chris Hostetter <ho...@fucit.org>.
: (Note that output formatter strikes again: this is wrong:
:
: > "q":"{!parent which=\"*:* is_child:false\"}(
: > odams.identifier:W0178F2)",
that is *probably* not a problem with solr -- it is typically an
indication that the way you are crafting/sending your HTTP request/url
includes an "un-escaped" "+" character in the URL which Jetty/Solr are
(required) to interpret as an escaped " " (space) character.
hossman@slate:~$ curl -sS 'http://localhost:8983/solr/gettingstarted/select?q=a+b' | grep -F '"q"'
"q":"a b"
hossman@slate:~$ curl -sS 'http://localhost:8983/solr/gettingstarted/select?' --form-string 'q=a+b' | grep -F '"q"'
"q":"a+b"
hossman@slate:~$ curl -sS 'http://localhost:8983/solr/gettingstarted/select?q=a%2Bb' | grep -F '"q"'
"q":"a+b"
-Hoss
http://www.lucidworks.com/
Re: why would "{!parent}" return a child document?
Posted by Dmitri Maziuk <dm...@gmail.com>.
On 12/12/25 16:22, Mikhail Khludnev wrote:
> Hello Dima,
> Look at
> "q":"{!parent which=\"*:* is_child:false\"}(
> it means SHOULD matchAll, SHOULD is_child:false
Oh, cool: The Fine Manual has `q={!parent which="*:* -_nest_path:*}`, in
which case "*:*" is actually required and minus is not ignored.
Whereas with my explicit `is_child` field, `q={!parent which="*:*
+is_child:false}` treats the plus as SHOULD, as you say, and not as MUST
that I naively expected.
Removing "*:*" fixes it, thank you.
(Note that output formatter strikes again: this is wrong:
> "q":"{!parent which=\"*:* is_child:false\"}(
> odams.identifier:W0178F2)",
and this is "only" half-wrong:
> "debug":{
> "rawquerystring":"{!parent which=\"*:* is_child:false\"}(
> odams.identifier:W0178F2)",
> "querystring":"{!parent which=\"*:* is_child:false\"}(
> odams.identifier:W0178F2)",
> "parsedquery":"AllParentsAware(ToParentBlockJoinQuery
> (+odams.identifier:W0178F2))",
> "parsedquery_toString":"ToParentBlockJoinQuery
> (+odams.identifier:W0178F2)",
)
> I'm noticing an unclosed double quote in the query above, it may freakn out
> the query parser which isn't bulletproof, you know.
That's a copy-paste-edit problem: I'm running queries on the sandboxed
work computer & posting to the ML from my "home" gmail acct involves
jumping through hoops.
Thank you,
Dima
Re: why would "{!parent}" return a child document?
Posted by Mikhail Khludnev <mk...@apache.org>.
Hello Dima,
Look at
"q":"{!parent which=\"*:* is_child:false\"}(
it means SHOULD matchAll, SHOULD is_child:false
You need just `{!parent which=is_child:false}...`
I'm noticing an unclosed double quote in the query above, it may freakn out
the query parser which isn't bulletproof, you know.
Enjoy
On Sat, Dec 13, 2025 at 12:58 AM Dmitri Maziuk <dm...@gmail.com>
wrote:
> Hi all,
>
> we're still struggling here with child documents, here's my problem du
> jour (solr 8.11):
>
> in the index:
> ```
> {
> "id": "W0178E6",
> "odams.identifier": "W0178E6",
> "is_child": false,
> ...
> "child_objects": [
> {
> "id": "W0178E6!W0178F2",
> "odams.identifier": "W0178F2",
> "is_child":true
> },
> ...
> ```
> with more children:
>
> "id": "W0178E6!W0178EX",
> "id": "W0178E6!W0178F9",
> "id": "W0178E6!W0178F7",
> "id": "W0178E6!W0178F3",
> "id": "W0178E6!W0178F1",
> "id": "W0178E6!W0178EZ",
> "id": "W0178E6!W0178EY",
> "id": "W0178E6!W0178EO",
> "id": "W0178E6!W0178EM",
>
> My reading of The Fine Manual @
> https://solr.apache.org/guide/8_11/searching-nested-documents.html is that
> `q={!parent which="*:* +is_child:false}(+odams.identifier:W0178F2)`
> should return the parent: W0178E6.
>
> What I get instead is
> ```
> {
> "responseHeader":{
> "status":0,
> "QTime":18,
> "params":{
> "q":"{!parent which=\"*:* is_child:false\"}(
> odams.identifier:W0178F2)",
> "debugQuery":"true"}},
> "response":{"numFound":1,"start":0,"numFoundExact":true,"docs":[
> {
> ...
> "id":"W0178E6!W0178EX",
> "odams.identifier":"W0178EX",
> ...
> }]
> },
> "debug":{
> "rawquerystring":"{!parent which=\"*:* is_child:false\"}(
> odams.identifier:W0178F2)",
> "querystring":"{!parent which=\"*:* is_child:false\"}(
> odams.identifier:W0178F2)",
> "parsedquery":"AllParentsAware(ToParentBlockJoinQuery
> (+odams.identifier:W0178F2))",
> "parsedquery_toString":"ToParentBlockJoinQuery
> (+odams.identifier:W0178F2)",
> "explain":{
> "W0178E6!W0178EX":"\n0.0 = Not a match\n"},
> "QParser":"BlockJoinParentQParser",
> "timing":{
> ...
> ```
>
> Any ideas why?
> What does is even mean `"W0178E6!W0178EX":" 0.0 = Not a match"` with the
> "W0178E6!W0178EX" document returned?
>
> Any hints welcome, TIA
> Dima
>
>
--
Sincerely yours
Mikhail Khludnev