creates/updates a query to search for a certain property
975058
function _applyProp(property, value, obj) {
      obj = obj || {};
      obj[property] = value;
      return obj;
    }
62242
private function queryAddPropertySelect(\Smalldb\Flupdo\FlupdoBuilder $query, string $table_alias, string $property_name, array $property, string $property_prefix = '')
	{
		$table_q = $query->quoteIdent($table_alias);
		$p_q = $query->quoteIdent($property_name);
		$pa_q = $query->quoteIdent($property_prefix.$property_name);
		if (!empty($property['components'])) {
			foreach ($property['components'] as $component => $column) {
				if (!isset($this->properties[$column])) {
					// make sure the components are selected, but only if they are not standalone properties
					$column_q = $query->quoteIdent($column);
					$alias_q = $property_prefix !== '' ? $query->quoteIdent($property_prefix.$column) : $column_q;
					$query->select("$table_q.$column_q AS $alias_q");
				}
			}
		} else if ((!empty($property['is_calculated']) || !empty($property['calculated'])) && isset($property['sql_select'])) {
			// FIXME: Provide a symbol for the current table alias - this will not work when importing properties.
			$query->select("({$property['sql_select']}) AS $pa_q");
		} else {
			$query->select("$table_q.$p_q AS $pa_q");
		}
	}
369100
def search_update_index(self):
        
        doc_id = self.search_get_document_id(self.key)

        fields = [search.AtomField('class_name', name) for name in self.search_get_class_names()]

        index = self.search_get_index()

        if self.searchable_fields is None:
            searchable_fields = []

            for field, prop in self._properties.items():
                if field == 'class':
                    continue
                for class_, field_type in SEARCHABLE_PROPERTY_TYPES.items():
                    if isinstance(prop, class_):
                        searchable_fields.append(field)
        else:
            searchable_fields = self.searchable_fields

        for f in set(searchable_fields):
            prop = self._properties[f]
            value = getattr(self, f)
            field = None
            field_found = False
            for class_, field_type in SEARCHABLE_PROPERTY_TYPES.items():
                if isinstance(prop, class_):
                    field_found = True
                    if value is not None:
                        if isinstance(value, list) or isinstance(value, tuple) or isinstance(value, set):
                            for v in value:
                                field = field_type(name=f, value=v)
                        elif isinstance(value, ndb.Key):
                            field = field_type(name=f, value=value.urlsafe())
                        else:
                            field = field_type(name=f, value=value)
            if not field_found:
                raise ValueError('Cannot find field type for %r on %r' % (prop, self.__class__))

            if field is not None:
                fields.append(field)

        document = search.Document(doc_id, fields=fields)
        index.put(document)
553682
function (items, query) {
        if (!config.exactMatch || !config.searchField.name) {
          return items;
        }
        var list = items;
        var match = _.findIndex(list, function (item) {
          return query.toLowerCase() === item.name.toLowerCase();
        });
        if (match !== -1) {
          list.splice(0, 0, list.splice(match, 1)[0]);
        }
        return list;
      }
16896
function querySearch (query) {
      return query ? self.states.filter(createFilterFor(query)) : self.states;
    }
689962
function contains(query, node, info) {
  if (!has(node, info.property)) {
    return false
  }

  return (
    normalizeValue(node.properties[info.property], info).indexOf(
      query.value
    ) !== -1
  )
}
497891
def actual_query(self):
        """"""
        if not self._actual_query:

            # trigger evaluation of operation
            if (self.operation in ['query', 'getmore', 'update', 'remove'] or
                    self.command in ['count', 'findandmodify']):
                self._actual_query = self._find_pattern('query: ', actual=True)
            elif self.command == 'find':
                self._actual_query = self._find_pattern('filter: ',
                                                        actual=True)

        return self._actual_query
780927
def query(cls, owner=None, name=None, offset=None, limit=None, api=None):
        
        api = api if api else cls._API
        query_params = {}
        if owner:
            url = cls._URL['query'].format(owner=owner)
        else:
            url = cls._URL['query'].format(owner='')
        if name:
            query_params['name'] = name
        return super(Project, cls)._query(
            url=url, offset=offset, limit=limit, fields='_all',
            api=api, **query_params
        )
1272056
def search(self, query, fields=None, page=1, max_records=None, flatten=True):
        """"""
        if fields is None:
            fields = []
        page = int(page)
        pages = float('inf')
        data = {
            "query": query,
            "page": page,
            "fields": fields,
            "flatten": flatten
        }

        count = 0
        while page <= pages:
            payload = self._post(self.search_path, data=data)
            pages = payload['metadata']['pages']
            page += 1
            data["page"] = page

            for result in payload["results"]:
                yield result
                count += 1
                if max_records and count >= max_records:
                    return
1075027
def query_under_condition(condition, kind='2'):
        '''
        
        '''
        if DB_CFG['kind'] == 's':
            return TabPost.select().where(
                (TabPost.kind == kind) & (TabPost.valid == 1)
            ).order_by(
                TabPost.time_update.desc()
            )

        return TabPost.select().where(
            (TabPost.kind == kind) &
            (TabPost.valid == 1) &
            TabPost.extinfo.contains(condition)
        ).order_by(TabPost.time_update.desc())
1130959
def search_by_name(cls, query, name):
        
        query = query.filter(db.or_(cls.first_name.contains(name),
                                    cls.last_name.contains(name)))
        return query
1093347
def update(self, *args, **kwargs):
        
        if args:
            for arg in args:
                if not isinstance(arg, ScriptField):
                    raise InvalidParameter("%s this must be a ScriptField or derivated" % arg)

        query = self._build_query()
        connection = self.model._meta.dj_connection
        query.fields = ["_id", "_type", "_index"]
        # results = connection.connection.search(query, indices=connection.database, doc_types=self.type,
        #                             model=self.model, scan=True)

        conn = connection.connection
        results = conn.search(query, indices=connection.database, doc_types=self.type, scan=True)

        for item in results:
            if kwargs:
                conn.update(item._meta.index, item._meta.type, item._meta.id, document=kwargs, bulk=True)
            for script in args:
                conn.update(item._meta.index, item._meta.type, item._meta.id,
                            script=script.script, lang=script.lang, params=script.params, bulk=True)

        connection.connection.flush_bulk(True)
        # Clear the result cache, in case this QuerySet gets reused.
        self._result_cache = None
717545
def apply(self, search, field, value):
        """"""
        return search.query(
            self.query_type(  # pylint: disable=not-callable
                **{
                    field: {
                        self.operator: self.get_value_query(value)
                    }
                }
            )
        )
299955
function(query) {
    var i;
    var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];

    // stem the searchterms and add them to the correct list
    var stemmer = new Stemmer();
    var searchterms = [];
    var excluded = [];
    var hlterms = [];
    var tmp = splitQuery(query);
    var objectterms = [];
    for (i = 0; i < tmp.length; i++) {
      if (tmp[i] !== "") {
          objectterms.push(tmp[i].toLowerCase());
      }

      if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) ||
          tmp[i] === "") {
        // skip this "word"
        continue;
      }
      // stem the word
      var word = stemmer.stemWord(tmp[i].toLowerCase());
      // prevent stemmer from cutting word smaller than two chars
      if(word.length < 3 && tmp[i].length >= 3) {
        word = tmp[i];
      }
      var toAppend;
      // select the correct list
      if (word[0] == '-') {
        toAppend = excluded;
        word = word.substr(1);
      }
      else {
        toAppend = searchterms;
        hlterms.push(tmp[i].toLowerCase());
      }
      // only add if not already in the list
      if (!$u.contains(toAppend, word))
        toAppend.push(word);
    }
    var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));

    // console.debug('SEARCH: searching for:');
    // console.info('required: ', searchterms);
    // console.info('excluded: ', excluded);

    // prepare search
    var terms = this._index.terms;
    var titleterms = this._index.titleterms;

    // array of [filename, title, anchor, descr, score]
    var results = [];
    $('#search-progress').empty();

    // lookup as object
    for (i = 0; i < objectterms.length; i++) {
      var others = [].concat(objectterms.slice(0, i),
                             objectterms.slice(i+1, objectterms.length));
      results = results.concat(this.performObjectSearch(objectterms[i], others));
    }

    // lookup as search terms in fulltext
    results = results.concat(this.performTermsSearch(searchterms, excluded, terms, titleterms));

    // let the scorer override scores with a custom scoring function
    if (Scorer.score) {
      for (i = 0; i < results.length; i++)
        results[i][4] = Scorer.score(results[i]);
    }

    // now sort the results by score (in opposite order of appearance, since the
    // display function below uses pop() to retrieve items) and then
    // alphabetically
    results.sort(function(a, b) {
      var left = a[4];
      var right = b[4];
      if (left > right) {
        return 1;
      } else if (left < right) {
        return -1;
      } else {
        // same score: sort alphabetically
        left = a[1].toLowerCase();
        right = b[1].toLowerCase();
        return (left > right) ? -1 : ((left < right) ? 1 : 0);
      }
    });

    // for debugging
    //Search.lastresults = results.slice();  // a copy
    //console.info('search results:', Search.lastresults);

    // print the results
    var resultCount = results.length;
    function displayNextItem() {
      // results left, load the summary and display it
      if (results.length) {
        var item = results.pop();
        var listItem = $('<li style="display:none"></li>');
        if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {
          // dirhtml builder
          var dirname = item[0] + '/';
          if (dirname.match(/\/index\/$/)) {
            dirname = dirname.substring(0, dirname.length-6);
          } else if (dirname == 'index/') {
            dirname = '';
          }
          listItem.append($('<a/>').attr('href',
            DOCUMENTATION_OPTIONS.URL_ROOT + dirname +
            highlightstring + item[2]).html(item[1]));
        } else {
          // normal html builders
          listItem.append($('<a/>').attr('href',
            item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
            highlightstring + item[2]).html(item[1]));
        }
        if (item[3]) {
          listItem.append($('<span> (' + item[3] + ')</span>'));
          Search.output.append(listItem);
          listItem.slideDown(5, function() {
            displayNextItem();
          });
        } else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
          var suffix = DOCUMENTATION_OPTIONS.SOURCELINK_SUFFIX;
          $.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[5] + (item[5].slice(-suffix.length) === suffix ? '' : suffix),
                  dataType: "text",
                  complete: function(jqxhr, textstatus) {
                    var data = jqxhr.responseText;
                    if (data !== '' && data !== undefined) {
                      listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
                    }
                    Search.output.append(listItem);
                    listItem.slideDown(5, function() {
                      displayNextItem();
                    });
                  }});
        } else {
          // no source available, just display title
          Search.output.append(listItem);
          listItem.slideDown(5, function() {
            displayNextItem();
          });
        }
      }
      // search finished, update title and status message
      else {
        Search.stopPulse();
        Search.title.text(_('Search Results'));
        if (!resultCount)
          Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
        else
            Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
        Search.status.fadeIn(500);
      }
    }
    displayNextItem();
  }
1100471
function(model, settings, options, cb) {
      var baseQuery, defaultSelect, k, query, v;
      if (settings == null) {
        settings = {};
      }
      if (options == null) {
        options = {};
      }
      if (cb == null) {
        cb = function() {};
      }
      Hoek.assert(model, i18n.assertModuleRequired);
      defaultSelect = settings.defaultSelect || null;
      baseQuery = settings.baseQuery || {};
      if (_.isFunction(options)) {
        cb = options;
        options = {};
      }
      options.where || (options.where = {});
      options.select || (options.select = defaultSelect);
      for (k in baseQuery) {
        v = baseQuery[k];
        options.where[k] = v;
      }
      query = model.findOne(options.where);
      if (options.select && options.select.length > 0) {
        query = query.select(options.select);
      }
      return query.exec(cb);
    }
386134
function(query) {
                    tsdb.searchLookup(query, true, null, function (data) {
                        receivedResponses++;
                        results.push(perResultFn(query,data));
                        if (receivedResponses == expectedResponses) {
                            if (errorsReceived.length == 0) {
                                successFn(results);
                            }
                            else {
                                errorFn(errorsReceived, results);
                            }

                        }
                    }, function (error) {
                        receivedResponses++;
                        errorsReceived.push({query:query,msg:error});
                        if (receivedResponses == expectedResponses) {
                            errorFn(errorsReceived, results);
                        }
                    });
                }
147712
def matches_query(self, key, query):
        
        dumped = query.dump()
        dumped['className'] = query._query_class._class_name
        self._add_condition(key, '$inQuery', dumped)
        return self