(self, view_name, analyzer_name, query_string=None,
                 query_dsl=None, query_filter=None, additional_fields=None)
return view
Add saved view to the Sketch.

        Args:
            view_name: The name of the view.
            analyzer_name: The name of the analyzer.
            query_string: OpenSearch query string.
            query_dsl: Dictionary with OpenSearch DSL query.
            query_filter: Dictionary with OpenSearch filters.
            additional_fields: A list with field names to include in the
                view output.

        Raises:
            ValueError: If both query_string an query_dsl are missing.

        Returns: An instance of a SQLAlchemy View object.
Add saved view to the Sketch.
Add saved view to the Sketch .
def add_view(self, view_name, analyzer_name, query_string=None,
                 query_dsl=None, query_filter=None, additional_fields=None):
        """Add saved view to the Sketch.

        Args:
            view_name: The name of the view.
            analyzer_name: The name of the analyzer.
            query_string: OpenSearch query string.
            query_dsl: Dictionary with OpenSearch DSL query.
            query_filter: Dictionary with OpenSearch filters.
            additional_fields: A list with field names to include in the
                view output.

        Raises:
            ValueError: If both query_string an query_dsl are missing.

        Returns: An instance of a SQLAlchemy View object.
        """
        if not (query_string or query_dsl):
            raise ValueError('Both query_string and query_dsl are missing.')

        if not query_filter:
            query_filter = {'indices': '_all'}

        if additional_fields:
            query_filter['fields'] = [
                {'field': x.strip()} for x in additional_fields]

        description = 'analyzer: {0:s}'.format(analyzer_name)
        view = View.get_or_create(
            name=view_name, description=description, sketch=self.sql_sketch,
            user=None)
        view.description = description
        view.query_string = query_string
        view.query_filter = view.validate_filter(query_filter)
        view.query_dsl = query_dsl
        view.searchtemplate = None
        view.set_status(status='new')

        db_session.add(view)
        db_session.commit()
        return view
def add_view ( self , view_name , analyzer_name , query_string = None , query_dsl = None , query_filter = None , additional_fields = None ) : if not ( query_string or query_dsl ) : raise ValueError ( 'Both query_string and query_dsl are missing.' ) if not query_filter : query_filter = { 'indices' : '_all' } if additional_fields : query_filter [ 'fields' ] = [ { 'field' : x . strip ( ) } for x in additional_fields ] description = 'analyzer: {0:s}' . format ( analyzer_name ) view = View . get_or_create ( name = view_name , description = description , sketch = self . sql_sketch , user = None ) view . description = description view . query_string = query_string view . query_filter = view . validate_filter ( query_filter ) view . query_dsl = query_dsl view . searchtemplate = None view . set_status ( status = 'new' ) db_session . add ( view ) db_session . commit ( ) return view