Add support for script fields in frequency queries
authorJonathan Griffin <jgriffin@mozilla.com>
Tue, 14 Jun 2011 13:38:56 -0700
changeset 34 51afbd7578ffc80ec6c235d5ecce6dbd33ebcb6b
parent 33 ed46547d9991a3b27eb27f235f0f3177399a3c14
child 35 eb9808033c351e0ac76f131ca761f3cbf2714e7b
push id35
push userjgriffin@mozilla.com
push dateTue, 14 Jun 2011 20:39:07 +0000
Add support for script fields in frequency queries
mozautoeslib/eslib.py
--- a/mozautoeslib/eslib.py
+++ b/mozautoeslib/eslib.py
@@ -277,17 +277,20 @@ class ESLib(object):
 
     if doc_type:
       self.doc_type = doc_type
 
     boolquery = self._make_bool_query(include, exclude)
 
     q = Search(query=boolquery, size=0)
     for field in frequency_fields:
-      q.facet.add_term_facet(field, size=size)
+      if type(field) == basestring:
+        q.facet.add_term_facet(field, size=size)
+      else:
+        q.facet.add_term_facet(field['field'], size=size, script=field['script'])
 
     result = self.connection.search(query=q,
                                     indexes=[self.read_index],
                                     doc_types=self.doc_type)
 
     if 'facets' in result:
       return result['facets']