Selects facets to return for the domain.
976909
public SearchOptions addFacets(@Nullable Collection<String> f) {
    if (f != null) {
      this.facets.addAll(f);
    }
    return this;
  }
212361
def select(self, name):
    '''
    
    '''
    return PluginSet(self.group, name, [
      plug for plug in self.plugins if plug.name == name])
1299144
def select(self, cols, mode='list'):
        
        if isinstance(cols, stringtypes):
            cols = _split_cols(cols)
        if not cols:
            cols = [f.name for f in self.fields]
        return select_rows(cols, self, mode=mode)
192854
def list_subdomains(self, domain, limit=None, offset=None):
        
        return domain.list_subdomains(limit=limit, offset=offset)
654530
def select(cls, dataset, selection_mask=None, **selection):
        
        if not dataset.data:
            return []
        ds = cls._inner_dataset_template(dataset)
        data = []
        for d in dataset.data:
            ds.data = d
            sel = ds.interface.select(ds, **selection)
            data.append(sel)
        return data
1057304
function (db, indexName, facetDoc, query, cb) {
			var url = host + "databases/" + db + "/facets/" + indexName + "?facetDoc=" + facetDoc + "&query=" + encodeURIComponent(query);
			request(url, function (error, response, body) {
				if (!error && response.statusCode === 200) {
					var result = JSON.parse(body);
					_.each(result.Results, function (v, k) {
						if (_.filter(v.Values, function (x) {
							return x.Hits > 0;
						}).length < 2) {
							delete result.Results[k];
							return;
						}
						v.Values = _.chain(v.Values)
							.map(function (x) {
								var val = JSON.stringify(x.Range)
									.replace(/^\"|\"$/gi, "")
									.replace(/\:/gi, "\\:")
									.replace(/\(/gi, "\\(")
									.replace(/\)/gi, "\\)");
								if (x.Range.indexOf(" TO ") <= 0 || x.Range.indexOf("[") !== 0) {
									val = val.replace(/\ /gi, "\\ ");
								}
								val = encodeURIComponent(val);
								x.q = k + ":" + val;
								x.Range = x.Range
									.replace(/^\[Dx/, "")
									.replace(/ Dx/, " ")
									.replace(/\]$/, "")
									.replace(/ TO /, "-");
								return x;
							}).filter(function (x) {
								return x.Hits > 0;
							}).sortBy(function (x) {
								return x.Range;
							}).value();
					});
					cb(null, result.Results);
				} else
					cb(error || new Error(response.statusCode), null);
			});
		}
1014606
def find(context, facet_name, *args)
      facet = find_facet(context, facet_name)

      if !facet
        return nil
      end

      case result = facet.find(*args)
      when Array
        result.map { |item| @entities[item] }
      when String
        @entities[result]
      when NilClass
        nil
      else
        raise "Bad facet return type #{result.class.name.dump}"
      end
    end
47450
def drill_down_facets
      drill = drill_down.reverse
      i = drill.find_index{|f|f.selected?}
      if i == 0
        down = nil
	current, *ups = drill[0..-1]
      else
        down, current, *ups = drill[i-1..-1]
      end

      [ down, current, ups ]
    end
941559
protected function getActiveFacets($arguments)
    {
        $activeFacets = [];

        // Add facets activated by default.
        foreach ($this->settings['facets'] as $facet) {
            if (!empty($facet['selectedByDefault'])) {
                $this->setActiveFacetSelectionForID($activeFacets, $facet['id'], $facet['selectedByDefault']);
            }
        }

        // Add facets activated by query parameters.
        if (array_key_exists('facet', $arguments)) {
            foreach ($arguments['facet'] as $facetID => $facetSelection) {
                $this->setActiveFacetSelectionForID($activeFacets, $facetID, $facetSelection);
            }
        }

        return $activeFacets;
    }
1156143
def find_subdomains(domain):
    """"""
    result = set()
    response = get('https://findsubdomains.com/subdomains-of/' + domain).text
    matches = findall(r'(?s)<div class="domains js-domain-name">(.*?)</div>', response)
    for match in matches:
        result.add(match.replace(' ', '').replace('\n', ''))
    return list(result)
226285
def lookup_domains(self):
        
        thread_error = False
        thread_wait_timeout = 200
        ind = 1
        total_item_count = len(self.domains)
        for domain in self.domains:
            for nameserver in self.nameservers:
                wait_time = 0
                while threading.active_count() > self.max_threads:
                    time.sleep(1)
                    wait_time += 1
                    if wait_time > thread_wait_timeout:
                        thread_error = True
                        break

                if thread_error:
                    self.results["error"] = "Threads took too long to finish."
                    break
                log_prefix = "%d/%d: " % (ind, total_item_count)
                thread = threading.Thread(target=self.lookup_domain,
                                          args=(domain, nameserver,
                                                log_prefix))
                thread.setDaemon(1)

                thread_open_success = False
                retries = 0
                while not thread_open_success and retries < MAX_THREAD_START_RETRY:
                    try:
                        thread.start()
                        self.threads.append(thread)
                        thread_open_success = True
                    except:
                        retries += 1
                        time.sleep(THREAD_START_DELAY)
                        logging.error("%sThread start failed for %s, retrying... (%d/%d)" % (log_prefix, domain, retries, MAX_THREAD_START_RETRY))

                if retries == MAX_THREAD_START_RETRY:
                    logging.error("%sCan't start a new thread for %s after %d retries." % (log_prefix, domain, retries))

            if thread_error:
                break
            ind += 1

        for thread in self.threads:
            thread.join(self.timeout * 3)
        return self.results
1344931
def get_domains(self):
        
        if self.domains is None:
            self.domains = list(
                set(self.source.get_domains() + self.target.get_domains()))
        return self.domains
412158
def select_distinct(distinct_field=None, **kwargs):
    
    results = search_associations(rows=0,
                                  select_fields=[],
                                  facet_field_limits = {
                                      distinct_field : -1
                                  },
                                  facet_fields=[distinct_field],
                                  **kwargs
    )
    # TODO: map field
    return list(results['facet_counts'][distinct_field].keys())
1175881
@Override
  public FacetResult getFacetResult(String name) {
    if (facets == null || facets.isEmpty()) {
      return null;
    }
    return facets.get(name);
  }
742428
def get_domainaliases(self, domainid, page=None):
        """"""
        opts = {}
        if page:
            opts['page'] = page
        return self.api_call(
            ENDPOINTS['domainaliases']['list'],
            dict(domainid=domainid), **opts)
123306
def faceted_search(cls, query=None, filters=None, search=None):
        
        search_ = search or cls()

        class RecordsFacetedSearch(FacetedSearch):
            """Pass defaults from ``cls.Meta`` object."""

            index = prefix_index(app=current_app, index=search_._index[0])
            doc_types = getattr(search_.Meta, 'doc_types', ['_all'])
            fields = getattr(search_.Meta, 'fields', ('*', ))
            facets = getattr(search_.Meta, 'facets', {})

            def search(self):
                """Use ``search`` or ``cls()`` instead of default Search."""
                # Later versions of `elasticsearch-dsl` (>=5.1.0) changed the
                # Elasticsearch FacetedResponse class constructor signature.

                if ES_VERSION[0] > 2:
                    return search_.response_class(FacetedResponse)
                return search_.response_class(partial(FacetedResponse, self))

        return RecordsFacetedSearch(query=query, filters=filters or {})
293536
def get_computers(self, filterTerm=None, domain=None):
        

        cur = self.conn.cursor()

        # if we're returning a single host by ID
        if self.is_computer_valid(filterTerm):
            cur.execute("SELECT * FROM computers WHERE id=? LIMIT 1", [filterTerm])

        # if we're filtering by domain controllers
        elif filterTerm == 'dc':
            if domain:
                cur.execute("SELECT * FROM computers WHERE dc=1 AND LOWER(domain)=LOWER(?)", [domain])
            else:
                cur.execute("SELECT * FROM computers WHERE dc=1")

        # if we're filtering by ip/hostname
        elif filterTerm and filterTerm != "":
            cur.execute("SELECT * FROM computers WHERE ip LIKE ? OR LOWER(hostname) LIKE LOWER(?)", ['%{}%'.format(filterTerm), '%{}%'.format(filterTerm)])

        # otherwise return all computers
        else:
            cur.execute("SELECT * FROM computers")

        results = cur.fetchall()
        cur.close()
        return results