(self,
                                 query_analysis,
                                 db_name,
                                 collection_name)
return OrderedDict([('index',index_rec),
                            ('shellCommand', self.generate_shell_command(collection_name, index_rec))])
Generates an ideal query recommendation
Generates an ideal query recommendation
Generates an ideal query recommendation
def _generate_recommendation(self,
                                 query_analysis,
                                 db_name,
                                 collection_name):
        """Generates an ideal query recommendation"""
        index_rec = '{'
        for query_field in query_analysis['analyzedFields']:
            if query_field['fieldType'] is EQUIV_TYPE:
                if len(index_rec) is not 1:
                    index_rec += ', '
                index_rec += '"' + query_field['fieldName'] + '": 1'
        for query_field in query_analysis['analyzedFields']:
            if query_field['fieldType'] is SORT_TYPE:
                if len(index_rec) is not 1:
                    index_rec += ', '
                index_rec += '"' + query_field['fieldName'] + '": 1'
        for query_field in query_analysis['analyzedFields']:
            if query_field['fieldType'] is RANGE_TYPE:
                if len(index_rec) is not 1:
                    index_rec += ', '
                index_rec += '"' + query_field['fieldName'] + '": 1'
        index_rec += '}'

        # RECOMMENDATION
        return OrderedDict([('index',index_rec),
                            ('shellCommand', self.generate_shell_command(collection_name, index_rec))])
def _generate_recommendation ( self , query_analysis , db_name , collection_name ) : index_rec = '{' for query_field in query_analysis [ 'analyzedFields' ] : if query_field [ 'fieldType' ] is EQUIV_TYPE : if len ( index_rec ) is not 1 : index_rec += ', ' index_rec += '"' + query_field [ 'fieldName' ] + '": 1' for query_field in query_analysis [ 'analyzedFields' ] : if query_field [ 'fieldType' ] is SORT_TYPE : if len ( index_rec ) is not 1 : index_rec += ', ' index_rec += '"' + query_field [ 'fieldName' ] + '": 1' for query_field in query_analysis [ 'analyzedFields' ] : if query_field [ 'fieldType' ] is RANGE_TYPE : if len ( index_rec ) is not 1 : index_rec += ', ' index_rec += '"' + query_field [ 'fieldName' ] + '": 1' index_rec += '}' # RECOMMENDATION return OrderedDict ( [ ( 'index' , index_rec ) , ( 'shellCommand' , self . generate_shell_command ( collection_name , index_rec ) ) ] )