[
https://issues.apache.org/jira/browse/SOLR-216?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499273
]
Mike Klaas commented on SOLR-216:
---------------------------------
Thanks for your contribution! Some comments:
style:
- list comprehensions solely to perform looped execution are harder to parse
and slower than explicitly writing a for loop
- shadowing builtins is generally a bad idea
- SolrConnection is an old-style class, but Response is new-style
functionality:
- why are 'status'/'QTime' returned as floats?
- all NamedList's appearing in the output are converted to dicts--this loses
information (in particular, it will be unnecessarily hard for the user to use
highlighting/debug data). Using the python/json response format would prevent
this. Not returning highlight/debug data in the standard response format (and
yet providing said parameters in the query() method) seems odd. Am I missing
something? Oh, they are set as dynamic attributes of Response, I see.
Definitely needs documentation.
- passing fields='' to query() will return all fields, when the desired return
is likely no fields
- it might be better to settle on an api that permits doc/field boosts. How
about using a tuple as the field name in the field dict?
conn.add_many([{'id': 1, ('field2', 2.33): u"some text"}])
doc boosts could be handled by optionally providing the fielddict as a
(<fielddict>, boost) tuple.
- for 2.5+, a cool addition might be:
if sys.version > 2.5
import contextlib
def batched(solrconn):
solrconn.begin_batch()
yield solrconn
solrconn.end_batch()
batched = contextlib.contextmanager(batched)
Use as:
with batched(solrconn):
solrconn.add(...)
solrconn.add(...)
solrconn.add(...)
> Improvements to solr.py
> -----------------------
>
> Key: SOLR-216
> URL: https://issues.apache.org/jira/browse/SOLR-216
> Project: Solr
> Issue Type: Improvement
> Components: clients - python
> Affects Versions: 1.2
> Reporter: Jason Cater
> Priority: Trivial
> Attachments: solr.py
>
>
> I've taken the original solr.py code and extended it to include higher-level
> functions.
> * Requires python 2.3+
> * Supports SSL (https://) schema
> * Conforms (mostly) to PEP 8 -- the Python Style Guide
> * Provides a high-level results object with implicit data type conversion
> * Supports batching of update commands
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.