Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expressing constant score queries #6

Open
leforestier opened this issue Mar 31, 2018 · 3 comments
Open

Expressing constant score queries #6

leforestier opened this issue Mar 31, 2018 · 3 comments
Assignees

Comments

@leforestier
Copy link

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.

@swistakm
Copy link
Owner

swistakm commented Apr 1, 2018 via email

@leforestier
Copy link
Author

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.

@swistakm swistakm self-assigned this Apr 4, 2018
@swistakm
Copy link
Owner

swistakm commented Apr 4, 2018

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants