Saturday, March 17, 2018

FW: Parameter expansion and functions

-----Original Message-----
From: Dariusz Wojtas [mailto:dwojtas@gmail.com]
Sent: 13 March 2018 19:53
To: solr-user@lucene.apache.org
Subject: Parameter expansion and functions

Hi,

I am using SOLR 7.1
I've read some time ago the article
http://yonik.com/solr-query-parameter-substitution/
It's very helpful, knowing the trick with dummy parameter as a workaround in
some cases is very helpful.
${dummyParam:${localVariable}}

It is possible to use constructs like this in solrsonfig.xml <lst
name="defaults">
<str name="varA">10</str>
<str name="varB">${dummyParam:${varA}} and some other content</str>
</lst> It resolves as expected. This way I may calculate some parameters on
the fly.

But is there any chance to make this feature more complex?
Can I do something conditionally inside?
Can I use logical operators, or some other functions to construct local
parameters?
I know, one may say it may break security, etc.
Let it be turned off by default, let it require allowing local parameters by
name, to be allowed this. but can it be done?

My current need is to define the buusted query on the fly, but this feature
could help me in the past also. Example:

I have static 'q' param:
<str name="q">{!edismax
qf='idx_IDs^5 idx_names^3 idx_address^1'
v=$searchedTerms}</str>

Sometimes it is longer.
And I'd like to decide on the fly which fields should be included in the
query, same as their weights.
It works if I want to assign parametrized weight:
<str name="q">{!edismax
qf='idx_IDs^5 idx_names^3
idx_address^${dummyParam:${myWeightParam}}'
v=$searchedTerms}</str>

But can I make it more dynamic? Conditionals? I ytried with the {!switch
case.... default... v... } but it looks like this function expansion is
applied at some later stage, and it fails when I try to put it in "q"
definition.


Best regards,
Dariusz Wojtas

No comments:

Post a Comment