You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by krishan goyal <kr...@gmail.com> on 2020/09/21 14:13:34 UTC

How to use query function inside a function query in Solr LTR

Hi,

I have use cases of features which require a query function and some more
math on top of the result of the query function

Eg of a feature : no of extra terms in the document from input text

I am trying various ways of representing this feature but always getting an
exception
java.lang.RuntimeException: Exception from createWeight for SolrFeature
<feature>. Failed to parse feature query.

 Feature representations
"name" : "no_of_extra_terms",
"class" : "org.apache.solr.ltr.feature.SolrFeature",
"params": {
        "q": "{!func}sub(num_tokens_int,query({!dismax
qf=field_name}${text}))"
},

where num_tokens_int is a stored field which contains no of tokens in the
document


Also, feature representation with just a query parser like

"q": "{!dismax df=field_name}${text}"

works but I can't really getting my desired feature representation without
using it in a function query where i want to operate on the result of this
query to derive my actual feature

Re: How to use query function inside a function query in Solr LTR

Posted by krishan goyal <kr...@gmail.com>.
This is solved by using local parameters. So

{!func}sub(num_tokens_int,query({!dismax qf=field_name v=${text}}))

works


On Mon, Sep 21, 2020 at 7:43 PM krishan goyal <kr...@gmail.com> wrote:

> Hi,
>
> I have use cases of features which require a query function and some more
> math on top of the result of the query function
>
> Eg of a feature : no of extra terms in the document from input text
>
> I am trying various ways of representing this feature but always getting
> an exception
> java.lang.RuntimeException: Exception from createWeight for SolrFeature
> <feature>. Failed to parse feature query.
>
>  Feature representations
> "name" : "no_of_extra_terms",
> "class" : "org.apache.solr.ltr.feature.SolrFeature",
> "params": {
>         "q": "{!func}sub(num_tokens_int,query({!dismax
> qf=field_name}${text}))"
> },
>
> where num_tokens_int is a stored field which contains no of tokens in the
> document
>
>
> Also, feature representation with just a query parser like
>
> "q": "{!dismax df=field_name}${text}"
>
> works but I can't really getting my desired feature representation without
> using it in a function query where i want to operate on the result of this
> query to derive my actual feature
>