Search into a facet value
557676
public JSONObject searchInFacetValues(String facetName, String facetQuery, Query params) throws AlgoliaException {
    return this.searchInFacetValues(facetName, facetQuery, params, RequestOptions.empty);
  }
667742
def __search(self, obj, item, parent="root", parents_ids=frozenset({})):
        """"""

        if self.__skip_this(item, parent):
            return

        elif isinstance(obj, strings) and isinstance(item, strings):
            self.__search_str(obj, item, parent)

        elif isinstance(obj, strings) and isinstance(item, numbers):
            return

        elif isinstance(obj, numbers):
            self.__search_numbers(obj, item, parent)

        elif isinstance(obj, MutableMapping):
            self.__search_dict(obj, item, parent, parents_ids)

        elif isinstance(obj, tuple):
            self.__search_tuple(obj, item, parent, parents_ids)

        elif isinstance(obj, (set, frozenset)):
            if self.warning_num < 10:
                logger.warning(
                    "Set item detected in the path."
                    "'set' objects do NOT support indexing. But DeepSearch will still report a path."
                )
                self.warning_num += 1
            self.__search_iterable(obj, item, parent, parents_ids)

        elif isinstance(obj, Iterable):
            self.__search_iterable(obj, item, parent, parents_ids)

        else:
            self.__search_obj(obj, item, parent, parents_ids)
1289065
private Collection<Facet> filter(Collection<Facet> facets) {
        if (NotStopWordPredicate == null) {
            return facets;
        }

        return facets.stream()
                     .filter(NotStopWordPredicate)
                     .collect(Collectors.toList());

    }
849484
def search(self):
        """"""

        matches = []
        for index, cell in enumerate(self.cells):
            for pattern in Config.patterns:
                if ismatch(cell, pattern):
                    matches.append(index)
                    break

        return matches
1341689
def _prepare_facet_field_spies(self, facets):
        
        spies = []
        for facet in facets:
            slot = self.column[facet]
            spy = xapian.ValueCountMatchSpy(slot)
            # add attribute "slot" to know which column this spy is targeting.
            spy.slot = slot
            spies.append(spy)
        return spies
1195768
def get(self, key, value):
        """"""
        for element in self.neoindex[key][value]:
            if self.indexClass == "vertex":
                yield Vertex(element)
            elif self.indexClass == "edge":
                yield Edge(element)
            else:
                raise TypeError(self.indexClass)
150362
def to_internal_value(self, value):
        """"""
        if value == "":
            return None

        if isinstance(value, string_types):
            slug = slugify(value)
            feature_type, created = FeatureType.objects.get_or_create(
                slug=slug,
                defaults={"name": value}
            )
        else:
            if "id" in value:
                feature_type = FeatureType.objects.get(id=value["id"])
            elif "slug" in value:
                feature_type = FeatureType.objects.get(slug=value["slug"])
            else:
                raise ValidationError("Invalid feature type data")
        return feature_type
1116214
def run_with_search(model_path, config, num_days):
    """"""
    from indra.tools.machine.machine import run_with_search_helper
    run_with_search_helper(model_path, config, num_days=num_days)
410167
def search_golr_wrap(id, category, **args):
    
    #assocs1 = search_associations_compact(object=id, subject_category=category, **args)
    #assocs2 = search_associations_compact(subject=id, object_category=category, **args)
    assocs1, facets1 = search_compact_wrap(object=id, subject_category=category, **args)
    assocs2, facets2 = search_compact_wrap(subject=id, object_category=category, **args)
    facets = facets1
    if len(assocs2) > 0:
        facets = facets2
    return assocs1 + assocs2, facets
454936
def generic_key_facets(self, request):
        """"""

        excluded_apps = Q(app_label__in=EXCLUDED_APPS_FROM_FACETS)
        excluded_models = Q()
        for app_label, model in EXCLUDED_MODELS_FROM_FACETS:
            excluded_models = excluded_models | Q(app_label=app_label,
                    model=model)
        values = "model", "app_label", "id"
        content_types = ContentType.objects.values_list(*values) \
                .exclude(excluded_apps | excluded_models)
        return JsonResponse(dict([(str(a), {"app_label": str(b), "id": str(c)})
                for a, b, c in content_types]))
510774
def get_vals(self, field, goids=None):
        """"""
        go2nt = self.go2nt
        if goids is None:
            goids = set(go2nt)
        return [getattr(go2nt[go], field) for go in goids]
194026
def distinct_values_of(self, field, count_deleted=False):
        
        solr_params = "facet=true&facet.field=%s&rows=0" % field
        result = self.riak_http_search_query(self.index_name, solr_params, count_deleted)
        facet_fields = result['facet_counts']['facet_fields'][field]
        keys = facet_fields[0::2]
        vals = facet_fields[1::2]

        return dict(zip(keys, vals))
1260521
def _traverse_results(value, fields, row, path):
    
    for f, v in value.iteritems():  # for each item in obj
        field_name = '{path}.{name}'.format(path=path, name=f) if path else f

        if not isinstance(v, (dict, list, tuple)):  # if not data structure
            if field_name in fields:
                row[fields.index(field_name)] = ensure_utf(v)

        elif isinstance(v, dict) and f != 'attributes':  # it is a dict
            _traverse_results(v, fields, row, field_name)
952812
def get_available_facets(self):
        
        result = []
        for k, v in list(self.properties.items()):
            if isinstance(v, DateField):
                if not v.tokenize:
                    result.append((k, "date"))
            elif isinstance(v, NumericFieldAbstract):
                result.append((k, "numeric"))
            elif isinstance(v, StringField):
                if not v.tokenize:
                    result.append((k, "term"))
            elif isinstance(v, GeoPointField):
                if not v.tokenize:
                    result.append((k, "geo"))
            elif isinstance(v, ObjectField):
                for n, t in self.get_available_facets():
                    result.append((self.name + "." + k, t))
        return result
1175881
@Override
  public FacetResult getFacetResult(String name) {
    if (facets == null || facets.isEmpty()) {
      return null;
    }
    return facets.get(name);
  }
478459
def _process_search_results(self,
                                results: pysolr.Results) -> SearchResults:
        

        # map go-golr fields to standard
        for doc in results.docs:
            if 'entity' in doc:
                doc['id'] = doc['entity']
                doc['label'] = doc['entity_label']

        highlighting = {
            doc['id']: self._process_highlight(results, doc)._asdict()
            for doc in results.docs if results.highlighting
        }
        payload = SearchResults(
            facet_counts=translate_facet_field(results.facets),
            highlighting=highlighting,
            docs=results.docs,
            numFound=results.hits
        )
        logging.debug('Docs: {}'.format(len(results.docs)))

        return payload
435573
def get(self, request, *args, **kwargs):
        """"""

        form_class = self.get_form_class()
        form = self.get_form(form_class)

        top_value = self.get_top_level_facet_value()
        subfacets = SEARCH_SUBFACETS.get(top_value, [])
        self.active_facets = [self.top_facet] + subfacets

        if form.is_valid():
            self.query = form.cleaned_data.get(self.search_field)
        else:
            self.query = ""

        sqs = self.pre_facet_sqs()

        for facet in self.active_facets:
            sqs = facet.set_on_sqs(sqs)

        facet_counts = sqs.facet_counts()

        for facet in self.active_facets:
            facet.set_values_from_sqs_facet_counts(facet_counts)
            facet.apply_request_and_page_to_values(self.request, self.fluent_page)

        for facet in self.active_facets:
            sqs = facet.narrow_sqs(sqs)

        context = self.get_context_data(**{
            self.form_name: form,
            'facets': self.active_facets,
            'top_facet': self.top_facet,
            'query': self.query,
            'object_list': sqs,
            'page': self.fluent_page,
            'show_placeholders': self.show_placeholders()
        })
        return self.render_to_response(context)