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

Allow boost_relevancy() to use the same queries as query() #30

Open
markbirbeck opened this issue Oct 2, 2011 · 0 comments
Open

Allow boost_relevancy() to use the same queries as query() #30

markbirbeck opened this issue Oct 2, 2011 · 0 comments

Comments

@markbirbeck
Copy link

I have a query like this:

q = query.boost_relevancy(boost1, field1__lte=1000000).\
    boost_relevancy(boost2, field2__lte=10)

However, an exception is thrown saying that the fields don't exist in the schema. This is because the __lte part is not being taken into account.

There is already code in add() for checking field names without the __lte part, and by changing add_boost() to use this code, the exception goes and the query runs correctly:

def add_boost(self, kwargs, boost_score):
    for k, v in kwargs.items():
        try:
            field_name, rel = k.split("__")
        except ValueError:
            field_name, rel = k, 'eq'
        field = self.schema.match_field(field_name)
        if not field:
            if (k, v) != ("*", "*"):
                # the only case where wildcards in field names are allowed
                raise ValueError("%s is not a valid field name" % field_name)
        elif not field.indexed:
            raise SolrError("Can't query on non-indexed field '%s'" % field_name)
        value = field.instance_from_user_data(v)
    self.boosts.append((kwargs, boost_score))

Apologies for not providing a patch/pull request, but I'll try to follow up after next week -- for now I have a serious deadline to meet!

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

1 participant