def search_section(request, query, project_slug=None, version_slug=LATEST, path=None):
 kwargs = {}
 body = {'query': {'bool': {'should': [{'match_phrase': {'title': {'query': query, 'boost': 10, 'slop': 2}}}, {'match_phrase': {'content': {'query': query, 'slop': 5}}}]}}, 'facets': {'project': {'terms': {'field': 'project'}, 'facet_filter': {'term': {'version': version_slug}}}}, 'highlight': {'fields': {'title': {}, 'content': {}}}, 'fields': ['title', 'project', 'version', 'path', 'page_id', 'content'], 'size': 10}
 if project_slug:
  body['filter'] = {'and': [{'term': {'project': project_slug}}, {'term': {'version': version_slug}}]}
  body['facets']['path'] = ({'terms': {'field': 'path'}, 'facet_filter': {'term': {'project': project_slug}}},)
  kwargs['routing'] = project_slug
 if path:
  body['filter'] = {'and': [{'term': {'path': path}}]}
 if (path and (not project_slug)):
  body['facets']['path'] = {'terms': {'field': 'path'}}
 before_section_search.send(request=request, sender=PageIndex, body=body)
 return SectionIndex().search(body, **kwargs)

def search_section ( request , query , project_slug = None , version_slug = LATEST , path = None ) : kwargs = { } body = { 'query' : { 'bool' : { 'should' : [ { 'match_phrase' : { 'title' : { 'query' : query , 'boost' : 10 , 'slop' : 2 } } } , { 'match_phrase' : { 'content' : { 'query' : query , 'slop' : 5 } } } ] } } , 'facets' : { 'project' : { 'terms' : { 'field' : 'project' } , 'facet_filter' : { 'term' : { 'version' : version_slug } } } } , 'highlight' : { 'fields' : { 'title' : { } , 'content' : { } } } , 'fields' : [ 'title' , 'project' , 'version' , 'path' , 'page_id' , 'content' ] , 'size' : 10 } if project_slug : body [ 'filter' ] = { 'and' : [ { 'term' : { 'project' : project_slug } } , { 'term' : { 'version' : version_slug } } ] } body [ 'facets' ] [ 'path' ] = ( { 'terms' : { 'field' : 'path' } , 'facet_filter' : { 'term' : { 'project' : project_slug } } } , ) kwargs [ 'routing' ] = project_slug if path : body [ 'filter' ] = { 'and' : [ { 'term' : { 'path' : path } } ] } if ( path and ( not project_slug ) ) : body [ 'facets' ] [ 'path' ] = { 'terms' : { 'field' : 'path' } } before_section_search . send ( request = request , sender = PageIndex , body = body ) return SectionIndex ( ) . search ( body , ** kwargs )
search for a section of content when you search .