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

Adding maxScore to result #38

Open
ghost opened this issue Jan 8, 2012 · 2 comments
Open

Adding maxScore to result #38

ghost opened this issue Jan 8, 2012 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 8, 2012

Hello -

I'm a new sunburnt user - so far it is working amazingly well for my project and I look forward to following the project.

For the work I'm doing, I've needed maxScore from SOLr, which was easy for me to add to the SolrResult object. (see line with self.maxScore below, that's the only change)

(sunburnt/schema.py):

class SolrResult(object):
    def __init__(self, schema, node):
        self.schema = schema
        self.name = node.attrib['name']
        self.numFound = int(node.attrib['numFound'])
        self.maxScore = node.attrib['maxScore'] # this is the only new line
        self.start = int(node.attrib['start'])
        self.docs = [schema.parse_result_doc(n) for n in node.xpath("doc")]

For now I am just ensuring that my virtualenv has that line in its sunburnt install, but would obviously love to see support added to the library at some point. I haven't had a chance to write any tests yet, but notice that perhaps a test of SolrResult initialization could be useful in general. I'm happy to work on that and other tests to support the project - just figured I'd send along the small issue comment to get started.

Best,
Megan.

@tow
Copy link
Owner

tow commented Jan 9, 2012

Hi Megan,

thanks for this, that's great. I've a feeling that maxScore isn't
always in the result object - when I first wrote sunburnt for Solr
1.3, I think I took care of everything that came in the result object.
Maybe that's changed in newer versions of Solr and now it's always
present. Might be good to make the relevant line be:

self.maxScore = node.attrib.get('maxScore')

instead, just in case someone is using this with an older version.
Also, would it be useful to convert the maxScore to a float as well?

And it would be great if you could work on some tests for SolrResult
initialization - it's definitely a hole in the current testsuite!
Indeed, any new tests would be more than welcome :-)

Thanks,
Toby

On 8 January 2012 17:47, megbragg
[email protected]
wrote:

Hello -

I'm a new sunburnt user - so far it is working amazingly well for my project and I look forward to following the project.

For the work I'm doing, I've needed maxScore from SOLr, which was easy for me to add to the SolrResult object. (see line with self.maxScore below, that's the only change)

(sunburnt/schema.py)
class SolrResult(object):
   def init(self, schema, node):
       self.schema = schema
       self.name = node.attrib['name']
       self.numFound = int(node.attrib['numFound'])
       self.maxScore = node.attrib['maxScore'] # this is the only new line
       self.start = int(node.attrib['start'])
       self.docs = [schema.parse_result_doc(n) for n in node.xpath("doc")]

For now I am just ensuring that my virtualenv has that line in its sunburnt install, but would obviously love to see support added to the library at some point. I haven't had a chance to write any tests yet, but notice that perhaps a test of SolrResult initialization could be useful in general. I'm happy to work on that and other tests to support the project - just figured I'd send along the small issue comment to get started.

Best,
Megan.


Reply to this email directly or view it on GitHub:
#38

@ghost
Copy link
Author

ghost commented Jan 9, 2012

Hi Toby -

Oops you're right, maxScore isn't always available, so it should be a more careful check. And I agree about converting to a float. (In my project, we are always exposing the score, which is why that has always worked for me :)

I'll work on some score detection for the SolrResult and conditionally adding maxScore to it, and some initialization tests.

Best,
Megan.

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