You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: searcher.go
    path of file: ./repos/bk-cmdb/src/source_controller/coreservice/core/host/searcher
    
    the code of the file until where you have to start completion: /*
 * Tencent is pleased to support the open source community by making 蓝鲸 available.,
 * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
 * Licensed under the MIT License (the ",License",); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 * http://opens
    
func (s *Searcher) ListHosts(ctx context.Context, option metadata.ListHosts) (searchResult *metadata.ListHostResult, err error) {
	rid := util.ExtractRequestIDFromContext(ctx)

	if key, err := option.Validate(); err != nil {
		blog.Errorf("ListHosts failed, invalid parameters, key: %s, err: %s, rid: %s", key, err.Error(), rid)
		return nil, err
	}

	relationFilter := map[string]interface{}{}
	if option.BizID != 0 {
		relationFilter[common.BKAppIDField] = option.BizID
	}

	if len(option.ModuleIDs) != 0 {
		relationFilter[common.BKModuleIDField] = map[string]interface{}{
			common.BKDBIN: option.ModuleIDs,
		}
	}

	if len(option.SetIDs) != 0 {
		relationFilter[common.BKSetIDField] = map[string]interface{}{
			common.BKDBIN: option.SetIDs,
		}
	}
	hostIDFilter := map[string]interface{}{}
	needHostIDFilter := false
	var hostIDs []interface{}
	if len(relationFilter) > 0 {
		needHostIDFilter = true
		var err error
		hostIDs, err = mongodb.Client().Table(common.BKTableNameModuleHostConfig).Distinct(ctx, common.BKHostIDField, relationFilter)
		if err != nil {
			blog.Errorf("ListHosts failed, db select failed, filter: %+v, err: %+v, rid: %s", relationFilter, err, rid)
			return nil, err
		}
		if len(hostIDs) == 0 {
			return &metadata.ListHostResult{
				Count: 0,
				Info:  []map[string]interface{}{},
			}, nil
		}

		hostIDFilter = map[string]interface{}{
			common.BKHostIDField: map[string]interface{}{
				common.BKDBIN: hostIDs,
			},
		}
	}
	filters := make([]map[string]interface{}, 0)
	if len(hostIDFilter) > 0 {
		filters = append(filters, hostIDFilter)
	}

	propertyFilter, err := option.GetHostPropertyFilter(ctx)
	if err != nil {
		blog.Errorf("ListHosts failed, db select failed, filter: %+v, err: %+v, rid: %s", hostIDFilter, err, rid)
		return nil, err
	}
	if len(propertyFilter) > 0 {
		filters = append(filters, propertyFilter)
	}

	finalFilter := map[string]interface{}{}
	finalFilter = util.SetQueryOwner(finalFilter, util.ExtractOwnerFromContext(ctx))
	if len(filters) > 0 {
		finalFilter[common.BKDBAND] = filters
	}

	if needHostIDFilter && len(filters) == 1 && option.BizID != 0 {
		sort := strings.TrimLeft(option.Page.Sort, "+-")
		if len(option.Page.Sort) == 0 || sort == common.BKHostIDField || strings.Contains(sort, ",") == false &&
			strings.HasPrefix(sort, common.BKHostIDField+":") {
			searchResult, err = s.listAllBizHostsPage(ctx, option.Fields, option.Page, hostIDs, rid)
			if err != nil {
				return nil, err
			}
			return searchResult, nil
		}

	}

	if len(filters) == 0 {
		// return info use cache
		// fix: has question when multi-supplier
		sort := strings.TrimLeft(option.Page.Sort, "+-")
		if len(option.Page.Sort) == 0 || sort == common.BKHostIDField || strings.Contains(sort, ",") == false &&
			strings.HasPrefix(sort, common.BKHostIDField+":") {
			var skip bool
			searchResult, skip, err = s.ListHostsWithCache(ctx, option.Fields, option.Page, rid)
			if err != nil {
				return nil, err
			}
			if skip == false {
				return searchResult, nil
			}
		}
	}

	total, err := mongodb.Client().Table(common.BKTableNameBaseHost).Find(finalFilter).Count(ctx)
	if err != nil {
		blog.Errorf("ListHosts failed, db select failed, filter: %+v, err: %+v, rid: %s", finalFilter, err, rid)
		return nil, err
	}
	searchResult = &metadata.ListHostResult{}
	searchResult.Count = int(total)

	limit := uint64(option.Page.Limit)
	start := uint64(option.Page.Start)
	query := mongodb.Client().Table(common.BKTableNameBaseHost).Find(finalFilter).Limit(limit).Start(start).Fields(option.Fields...)
	if len(option.Page.Sort) > 0 {
		query = query.Sort(option.Page.Sort)
	} else {
		query = query.Sort(common.BKHostIDField)
	}

	hosts := make([]metadata.HostMapStr, 0)
	if err := query.All(ctx, &hosts); err != nil {
		blog.Errorf("ListHosts failed, db select hosts failed, filter: %+v, err: %+v, rid: %s", finalFilter, err, rid)
		return nil, err
	}
	searchResult.Info = make([]map[string]interface{}, len(hosts))
	for index, host := range hosts {
		searchResult.Info[index] = host
	}
	return searchResult, nil
}