Permalink
Browse files

Added support for scope in TermFacet

  • Loading branch information...
Alberto Paro
Alberto Paro committed Feb 15, 2012
1 parent 4ea2bcb commit ed796d9c52f2fb9b5d221aa4bbb6229b30c3a4c0
Showing with 6 additions and 3 deletions.
  1. +6 −3 pyes/facets.py
View
@@ -234,7 +234,7 @@ class TermFacet(Facet):
def __init__(self, field=None, fields=None, name=None, size=10,
order=None, exclude=None,
regex=None, regex_flags="DOTALL",
- script=None, **kwargs):
+ script=None, scope=None, **kwargs):
super(TermFacet, self).__init__(**kwargs)
self.name = name
self.field = field
@@ -247,6 +247,7 @@ def __init__(self, field=None, fields=None, name=None, size=10,
self.regex = regex
self.regex_flags = regex_flags
self.script = script
+ self.scope = scope
def serialize(self):
if self.fields:
@@ -272,8 +273,10 @@ def serialize(self):
data['regex_flags'] = self.regex_flags
elif self.script:
data['script'] = self.script
-
- return {self.name:{self._internal_name:data}}
+ facet = {self._internal_name: data}
+ if self.scope:
+ facet['scope'] = self.scope
+ return {self.name: facet}
class TermStatsFacet(Facet):
_internal_name = "terms_stats"

0 comments on commit ed796d9

Please sign in to comment.