solrq
solrq copied to clipboard
Expressing constant score queries
Hi,
thanks for this library, it's very useful to me.
But I haven't found a way to express constant score queries using Q
.
(see https://lucene.apache.org/solr/guide/7_2/the-standard-query-parser.html or https://stackoverflow.com/a/46151908/1126971 ).
In Solr, they write it like this: field:value^=1
for example.
Using ^=
in Solrq is out of the question since you already use it to boost a Q
object in place.
But I'd really like a way to express these in Solrq.
Hi, it’s great to hear you find this library useful. We can definitely add support for this kind of queries.
Any idea what other python operator could be used for that feature? Or maybe you have some other idea for an API that would present the constant score queries in a concise and expressive way?
Wiadomość napisana przez Benjamin Le Forestier [email protected] w dniu 01.04.2018, o godz. 01:14:
Hi,
thanks for this library, it's very useful to me. But I haven't found a way to express constant score queries using Q. (see https://lucene.apache.org/solr/guide/7_2/the-standard-query-parser.html or https://stackoverflow.com/a/46151908/1126971 ). In Solr, they write it like this: field:value^=1 for example. Using ^= in Solrq is out of the question since you already use it to boost a Q object in place.
But I'd really like a way to express these in Solrq.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
There's not a lot of operators left unfortunately. The only one that could remind of the meaning of this particular type of query is ==
but I think overloading the ==
operator could be very misleading for someone who'd want to compare Q
objects to find out if they are equal.
So my suggestion would be to use a constant_score
method.
Q(field="value").constant_score(1) & Q(other_field="other value").constant_score(2.25)
It doesn't look so bad to me and it's easy to understand what it does.
@leforestier I like your design idea. Let's do it. I will prepare a separate branch with this feature this week. Will you want to review this as PR.