Query the index and return the processed results
198569
function queryIndex(query) {
  try {
    if (query.length) {
      var results = index.search(query);
      if (results.length === 0) {
        // Add a relaxed search in the title for the first word in the query
        // E.g. if the search is "ngCont guide" then we search for "ngCont guide titleWords:ngCont*"
        var titleQuery = 'titleWords:*' + query.split(' ', 1)[0] + '*';
        results = index.search(query + ' ' + titleQuery);
      }
      // Map the hits into info about each page to be returned as results
      return results.map(function(hit) { return pages[hit.ref]; });
    }
  } catch(e) {
    // If the search query cannot be parsed the index throws an error
    // Log it and recover
    console.log(e);
  }
  return [];
}
1189497
def query(self, query):
    ''''''
    results = super(SymlinkDatastore, self).query(query)
    return self._follow_link_gen(results)
186937
def _get_query_result(query, raw_result, **kwargs):
        
        if raw_result:
            return query(**kwargs)
        if kwargs:
            return QueryResult(query, **kwargs)

        return query.result
895512
function processResults(indexes) {
    // Contains all the information
    let info = {};
    // Process all the indexes
    for (let i = 0; i < indexes.length; i++) {
      const index = indexes[i];
      // Let's unpack the object
      info[index.name] = [];
      for (let name in index.key) {
        info[index.name].push([name, index.key[name]]);
      }
    }

    return info;
  }
815126
def index(self, *args, **kwargs):
        """"""
        self.check_session()
        result = self.session.index(*args, **kwargs)
        if self.autosession:
            self.commit()
        return result
94163
def execute_query(self, query, session):
		'''  '''
		self.auto_ensure_indexes(query.type)

		kwargs = dict()
		if query._get_fields():
			if PYMONGO_3: # pragma: nocover
				kwargs['projection'] = query._fields_expression()
			else: # pragma: nocover
				kwargs['fields'] = query._fields_expression()

		collection = self.db[query.type.get_collection_name()]
		
		if query._search:
			index_fields = query._createIndex
			if index_fields:
				# create new index
				if type(index_fields) is list:
					index_list = []
					for field in index_fields:
						index_list.append ((field, pymongo.TEXT))
					collection.create_index(index_list, name='search_index', default_language='english')
				else:
					raise InvalidConfigException()
			cursor = collection.find(query.query, {'__index_score': {'$meta': "textScore"}}, **kwargs)
			cursor.sort([('__index_score', {'$meta': 'textScore'})])
		elif query._rawquery:
			if query._query_type=='aggregate':
				cursor = collection.aggregate(query.query, cursor={}, **kwargs)
			elif query._query_type=='map_reduce':
				cursor = collection.map_reduce( query._mapreduce_mapper, query._mapreduce_reducer, query._mapreduce_key, query=query._mapreduce_query)
		else:
			cursor = collection.find(query.query, **kwargs)

		if query._sort:
			cursor.sort(query._sort)
		elif query.type.config_default_sort:
			cursor.sort(query.type.config_default_sort)
		if query.hints:
			cursor.hint(query.hints)
		if query._get_limit() is not None:
			cursor.limit(query._get_limit())
		if query._get_skip() is not None:
			cursor.skip(query._get_skip())
		return QueryResult(session, cursor, query.type, raw_output=query._raw_output, fields=query._get_fields())
280303
def query_mongo(
        database_name,
        collection_name,
        query={},
        include_num_results="0",
        skip=0,
        sort=None,
        limit=getattr(
            settings,
            'MONGO_LIMIT',
            200),
        cast_strings_to_integers=False,
        return_keys=()):
    """"""

    l = []
    response_dict = {}

    try:
        mongodb_client_url = getattr(settings, 'MONGODB_CLIENT',
                                 'mongodb://localhost:27017/')
        mc = MongoClient(mongodb_client_url,document_class=OrderedDict)

        db = mc[str(database_name)]
        collection = db[str(collection_name)]

        # Cast the query to integers
        if cast_strings_to_integers:
            query = cast_number_strings_to_integers(query)

        # print query
        if return_keys:
            return_dict = {}
            for k in return_keys:
                return_dict[k] = 1
            # print "returndict=",return_dict
            mysearchresult = collection.find(
                query, return_dict).skip(skip).limit(limit)
        else:
            mysearchresult = collection.find(query).skip(skip).limit(limit)

        if sort:
            mysearchresult.sort(sort)

        response_dict['code'] = 200
        if include_num_results == "1":
            response_dict['num_results'] = response_dict['num_results'] = int(
                mysearchresult.count(with_limit_and_skip=False))

        if include_num_results == "2":
            response_dict['num_results'] = response_dict['num_results'] = int(
                mysearchresult.count(with_limit_and_skip=True))

        response_dict['type'] = "search-results"
        for d in mysearchresult:
            d['id'] = d['_id'].__str__()
            del d['_id']
            l.append(d)
        response_dict['results'] = l

    except:
        print("Error reading from Mongo")
        print(str(sys.exc_info()))
        response_dict['num_results'] = 0
        response_dict['code'] = 500
        response_dict['type'] = "Error"
        response_dict['results'] = []
        response_dict['message'] = str(sys.exc_info())

    return response_dict
836833
def all_documents(index=INDEX_NAME):
    
    query = {
        'query': {
            'match_all': {}
        }
    }
    for result in raw_query(query, index=index):
        yield result
1093633
def process_query(self):
		
		self.query = wt(self.query)
		self.processed_query = []
		for word in self.query:
			if word not in self.stop_words and word not in self.punctuation:
				self.processed_query.append(self.stemmer.stem(word))
222401
def query(query):
    '''
    
    '''

    # send the query to the Gaia archive
    with warnings.catch_warnings() :
        warnings.filterwarnings("ignore")

        _gaia_job = astroquery.gaia.Gaia.launch_job(query)

        # return the table of results
        return _gaia_job.get_results()
906079
def fetch_data(self, **var):
        """"""
        varstr = ','.join(name + self._convert_indices(ind)
                          for name, ind in var.items())
        query = self.query().add_query_parameter(req='data', var=varstr)
        return self._fetch(query)
57796
def query(self):
        """"""

        if not hasattr(self, '_decoded_query'):
            self._decoded_query = list(urls._url_decode_impl(
                self.querystr.split('&'), 'utf-8', False, True, 'strict'))
        return self.query_cls(self._decoded_query)
1008514
def find_by_index(self, cls, index_name, value):
        """"""
        query_args = {
            index_name + '__eq': DynamoMappings.map_index_val(value),
            'index': gsi_name(index_name)
        }

        final_results = []
        for db_result in self.get_class_table(cls).query_2(**query_args):
            obj = cls.from_data(db_result['value'])
            final_results.append(obj)

        return final_results
554256
def index_queryset(self, using=None):
        """"""
        return self.get_model().objects.filter(
            modified__lte=datetime.datetime.now(),
            status=STATUS.published
        )
334239
def get_index(self, bucket, index, startkey, endkey=None,
                  return_terms=None, max_results=None, continuation=None,
                  timeout=None, term_regex=None):
        
        raise NotImplementedError
449283
def fetch_and_index(self, fetch_func):
        ""
        data, e = fetch_func()
        if e: raise e
        yield {row['id']: row for row in data}
1248488
def search(self, query, relation=None, index=0, limit=25, **kwargs):
        
        return self.get_object(
            "search", relation=relation, q=query, index=index, limit=limit, **kwargs
        )