def smart_search_prefix(self):
search_options = {}<EOL>extra_query = None<EOL>vrf_filter = None<EOL>if '<STR_LIT>' in request.json:<EOL><INDENT>search_options['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>if request.json['<STR_LIT>'] == '<STR_LIT:true>':<EOL><INDENT>search_options['<STR_LIT>'] = True<EOL><DEDENT>else:<EOL><INDENT>search_options['<STR_LIT>'] = False<EOL><DEDENT><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>if request.json['<STR_LIT>'] == '<STR_LIT:true>':<EOL><INDENT>search_options['<STR_LIT>'] = True<EOL><DEDENT>else:<EOL><INDENT>search_options['<STR_LIT>'] = False<EOL><DEDENT><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>search_options['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>search_options['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>if request.json['<STR_LIT>'] == '<STR_LIT:true>':<EOL><INDENT>search_options['<STR_LIT>'] = True<EOL><DEDENT>else:<EOL><INDENT>search_options['<STR_LIT>'] = False<EOL><DEDENT><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>if request.json['<STR_LIT>'] == '<STR_LIT:false>':<EOL><INDENT>search_options['<STR_LIT>'] = False<EOL><DEDENT>else:<EOL><INDENT>search_options['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>search_options['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>search_options['<STR_LIT>'] = request.json['<STR_LIT>']<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>vrf_filter_parts = []<EOL>vrfs = request.json['<STR_LIT>']<EOL>if len(vrfs) > <NUM_LIT:0>:<EOL><INDENT>vrf = vrfs[<NUM_LIT:0>]<EOL>vrf_filter = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': vrf if vrf != '<STR_LIT:null>' else None<EOL>}<EOL>for vrf in vrfs[<NUM_LIT:1>:]:<EOL><INDENT>vrf_filter = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': vrf_filter,<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': vrf if vrf != '<STR_LIT:null>' else None<EOL>}<EOL>}<EOL><DEDENT><DEDENT><DEDENT>if vrf_filter:<EOL><INDENT>extra_query = vrf_filter<EOL><DEDENT>if '<STR_LIT>' in request.json:<EOL><INDENT>if extra_query:<EOL><INDENT>extra_query = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': extra_query,<EOL>'<STR_LIT>': {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': request.json['<STR_LIT>']<EOL>}<EOL>}<EOL><DEDENT>else:<EOL><INDENT>extra_query = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': request.json['<STR_LIT>']<EOL>}<EOL><DEDENT><DEDENT>try:<EOL><INDENT>result = Prefix.smart_search(request.json['<STR_LIT>'],<EOL>search_options, extra_query)<EOL>del result['<STR_LIT:error>']<EOL><DEDENT>except NipapError as e:<EOL><INDENT>return json.dumps({'<STR_LIT:error>': <NUM_LIT:1>, '<STR_LIT:message>': e.args, '<STR_LIT:type>': type(e).__name__})<EOL><DEDENT>return json.dumps(result, cls=NipapJSONEncoder)<EOL>
Perform a smart search.

            The smart search function tries extract a query from
            a text string. This query is then passed to the search_prefix
            function, which performs the search.