Change format_text to format_explanation
Also fixes issues with it.
This commit is contained in:
Родитель
d316f47de0
Коммит
871fde507b
|
@ -89,8 +89,8 @@ Version 0.4: Released xxx
|
|||
* Added ``explain`` transform: it allows you to set the "explain" flag
|
||||
which gives you an explanation of how the score was calculated.
|
||||
|
||||
I also added ``elasticutils.utils.format_text`` which formats the
|
||||
resulting explanation text into something slightly more
|
||||
I also added ``elasticutils.utils.format_elasticutils`` which formats
|
||||
the resulting explanation text into something slightly more
|
||||
readable. But it's likely this will change in the future.
|
||||
|
||||
* Added ``boost`` transform: it allows you to do query-time field
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
def format_text(explanation, indent=' ', indent_level=0):
|
||||
def format_explanation(explanation, indent=' ', indent_level=0):
|
||||
"""Return explanation in an easier to read format
|
||||
|
||||
Easier to read for me, at least.
|
||||
|
||||
"""
|
||||
if not explanation:
|
||||
return ''
|
||||
|
||||
# Note: This is probably a crap implementation, but it's an
|
||||
# interesting starting point for a better formatter.
|
||||
|
@ -13,7 +15,7 @@ def format_text(explanation, indent=' ', indent_level=0):
|
|||
|
||||
if 'details' in explanation:
|
||||
details = '\n'.join(
|
||||
[format_text(subtree, indent, indent_level + 1)
|
||||
[format_explanation(subtree, indent, indent_level + 1)
|
||||
for subtree in explanation['details']])
|
||||
return line + '\n' + details
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче