No answers so far, but I have found a workaround that fits my needs. Maybe
it will help somebody in the future.
The solution is transparent to the client system.

Use the XSLT  response writer
 a. create a stylesheet that understands the query response XML format
 b. let's assume the query returns 3 top level documents, with identifiers
1, 2, 3.
 c. iterate over them and prepare URI to call for processing children
documents.
     In result it should be something like:

      /select
           ?q=_root_:(1 OR 2 OR 3)
           &fq=type:name
           &fq=<put something more if needed>
           &fl=id,parentId:_root_,childScore:product(0.15,
strdist("<searched value>",name_fullName,edit))

    I aliased the magic _root_ field with 'parentId' alias.
    _root_ field had to be changed to stored="true" in the schema,
otherwise the value would not be returned (by default index only field).
    I have also aliased the function result with the 'childScore' name.
    You may need to escape special charecters within hand-crafted URI.
    If so, use saxon, and you have access to the XSLT 2.0 encode-for-uri()
function - this will let you encode some parts of the URI.

 d. use the document() XSLT function for http subrequest from within the
XSLT transformation.
     Happily document() understands the 'http' protocol.
     All children docs processed with single sub-call within the main call!

 e. now process the main response with XSLT, update the score with the
results from the childDoc document.

 f. you may do whatever you want: add extra fields, update score, replace
code values with full text.

Works nicely even with 50 top level documents, each having 1-10 children.
Sub second response time to the client system, unnoticeable by the end user.

I really miss a way to call some aggreate function - in my case max() - on
a range of children documents call within LTR feature.
But XSLT with saxon have proven its value ;)
I could put it in wiki, with some more details, if somebody hinted me how
to do it.


Best regards,
Dariusz Wojtas


On Sun, Jan 21, 2018 at 12:35 PM, Dariusz Wojtas <dwoj...@gmail.com> wrote:

> Dear Solr Masters,
>
> I am using the LTR functionality with Solr, and it works beautifully.
> I have a nice catch-all query at the beginning, then I am recalculating
> the score with LTR.
> And I have already learned some nice tricks. but there is something that I
> still cannot do.
> I need to create LTR model features, that will operate on children
> document properties.
>
> Part of my doc structure:
> <doc>
>     <field name="id">b0001</field>
>     <field name="type">record</field>
>     <field name="gender">male</field>
>     <field name="fullName">Krzysztof Kowalski</field>
>     <doc>
>         <field name="id">d1e12</field>
>         <field name="type">name</field>
>         <field name="name_type">alias</field>
>         <field name="name_fullName">Chris Kowalski</field>
>     </doc>
>     <doc>
>         <field name="id">d1e18</field>
>         <field name="type">name</field>
>         <field name="name_type">spelling</field>
>         <field name="name_fullName">Krzysiek Kowalski</field>
>     </doc>
> </doc>
>
>
>
> What is pretty easy:
> 1. return strdist() between the given ${fullNameParam} and field 'fullName'
>     {
>         "store": "myStore",
>         "name": "scoreFullName",
>         "class": "org.apache.solr.ltr.feature.SolrFeature",
>         "params":{ "q": "{!func}strdist(\"${fullNameParam}\",fullName,edit)"
> }
>     }
>
> 2. I may also execute conditional evaluation, but only on top level
> document attributes.
>
>
> But what I do not know how to achieve is:
> *  return max(strdist()) of the given $fullNameParam against field
> 'name_fullName' in all children documents (type='name')*
>
> I need max() because there may be several children documents, I only need
> to find the top matching one.
> No, synonyms do not fit here. The example with names above is only a part
> of my data, there are other cases.
>
>
> Can this be done? How?
> I am returning the top level documents, where type='record'. But do not
> know how to achieve children evaluation result, where there may be many
> children documents.
> I've tried parent and child block join, with no luck.
>
> Best regards,
> Dariusz Wojtas
>

Reply via email to