Hello Mikhail,

For the example nested documents:

Example Indexing Syntax: Pseudo-Fields
https://solr.apache.org/guide/8_11/indexing-nested-documents.html#example-indexing-syntax

This sort works for me to sort products by their sku's price:

childfield(price_i,{!parent which='id:*prod' v='_nest_path_:/skus/*'}) desc

When I sorted by a string field (*color_s*) it also worked. However, if I
changed the string field to *color_s_lower* then it didn't work.
I guess the **_s_lower* field has docValues="false".

Note: The **_s_lowe*r field can be sorted if it is on the parent document
but  it cannot when it is in a nested document.

Do you know how to make the childfield() work with  *_s_lower field?

Thank you







On Sat, Nov 26, 2022 at 10:38 PM Mikhail Khludnev <[email protected]> wrote:

> Hello, Chatree.
> Please check about `of` param
>
> https://solr.apache.org/guide/solr/latest/query-guide/block-join-query-parser.html#block-mask
> It's really important note.
> I've made childfield() myself, so I can consult about it, but I don't know
> is those _nest_path. Unfortunately I'm unaware of them.
> Note, lucene query syntax uses colon to separate field:text, not =.
> That {!parent} query lacks a subordinate children query, ie. it should go
> after closing curly bracket } of before it via ... v='field:val'}.
> Pls keep us posted if you figure out the solution.
>
> On Sat, Nov 26, 2022 at 12:38 PM Chatree Srichart <
> [email protected]> wrote:
>
> > Hello all,
> >
> > I have these 2 parent documents and each of them has 2 children with
> > different nest paths (/path1, and /path2)
> >
> > [
> > {
> > "id": "parent_1",
> > "children": [
> > {
> > "id": "child_1.1",
> > "field": "value 1.1",
> > "_nest_path_": "/path1#"
> > },
> > {
> > "id": "child_1.2",
> > "field": "value 1.2",
> > "_nest_path_": "/path2#"
> > }
> > ]
> > },
> > {
> > "id": "parent_2",
> > "children": [
> > {
> > "id": "child_2.1",
> > "field": "value 2.1",
> > "_nest_path_": "/path1#"
> > },
> > {
> > "id": "child_2.2",
> > "field": "value 2.2",
> > "_nest_path_": "/path2#"
> > }
> > ]
> > }
> > ]
> >
> >
> > My question is:
> >
> > How to sort the parent documents by a field of a child document with
> > specific _nest_path?
> >
> > I see this in the Solr document:
> >
> > sort=childfield(field,{!parent of=…}…) desc allows to inline block join
> > parent query
> >
> >
> > *childfield(field) Function*
> > https://solr.apache.org/guide/8_11/function-queries.html
> >
> > However, I don't know what the of=... should be.
> >
> > I have already tried this:
> >
> > childfield(field,{!parent of='_nest_path_=/path1'}) desc
> >
> > but I always get this error:
> >
> > *Can't determine a Sort Order (asc or desc) in sort spec ...*
> >
> > Best regards,
> > Chatree Srichart
> >
>
>
> --
> Sincerely yours
> Mikhail Khludnev
>

Reply via email to