Get the items from the index using search after scrolling
166821
def get_elastic_items_search(elastic, search_after=None, size=None):
    

    if not size:
        size = DEFAULT_LIMIT

    url = elastic.index_url + "/_search"

    search_after_query = ''

    if search_after:
        logging.debug("Search after: %s", search_after)
        # timestamp uuid
        search_after_query = ', "search_after": [%i, "%s"] ' % (search_after[0], search_after[1])

    query = """
    {
        "size": %i,
        "query": {
            "bool": {
                "must": []
            }
        },
        "sort": [
            {"metadata__timestamp": "asc"},
            {"uuid": "asc"}
        ] %s

    }
    """ % (size, search_after_query)

    # logging.debug("%s\n%s", url, json.dumps(json.loads(query), indent=4))
    res = requests.post(url, data=query)

    rjson = None
    try:
        rjson = res.json()
    except Exception:
        logging.error("No JSON found in %s", res.text)
        logging.error("No results found from %s", url)

    return rjson
518621
def find(str)
      index = items.index {|i| i.index > current_row && i.name.start_with?(str)} || items.index {|i| i.name.start_with? str}
      move_cursor index if index
    end
69759
function (index) {
    var rawItem;
    var position = positions[index];

    try {
      rawItem = readEntry(position.start, position.end);
      return JSON.parse(rawItem);
    } catch (ex) {
      debug("ERROR reading item: %s -> %s", ex, rawItem);
    }
  }
930554
def find(self):
        """"""
        options = self.find_options.get_options()
        if options is None:
            return
        self.stop_and_reset_thread(ignore_results=True)
        self.search_thread = SearchThread(self)
        self.search_thread.sig_finished.connect(self.search_complete)
        self.search_thread.sig_current_file.connect(
            lambda x: self.status_bar.set_label_path(x, folder=False)
        )
        self.search_thread.sig_current_folder.connect(
            lambda x: self.status_bar.set_label_path(x, folder=True)
        )
        self.search_thread.sig_file_match.connect(
            self.result_browser.append_result
        )
        self.search_thread.sig_out_print.connect(
            lambda x: sys.stdout.write(str(x) + "\n")
        )
        self.status_bar.reset()
        self.result_browser.clear_title(
            self.find_options.search_text.currentText())
        self.search_thread.initialize(*options)
        self.search_thread.start()
        self.find_options.ok_button.setEnabled(False)
        self.find_options.stop_button.setEnabled(True)
        self.status_bar.show()
997375
def search(self, query=None, size=100, unpack=True):
        
        logging.info('Download all documents from index %s.', self.index)
        if query is None:
            query = self.match_all
        results = list()
        data = self.instance.search(index=self.index, doc_type=self.doc_type, body=query, size=size)
        if unpack:
            for items in data['hits']['hits']:
                if '_source' in items:
                    results.append(items['_source'])
                else:
                    results.append(items)
        else:
            results = data['hits']['hits']
        return results
1204215
def retrieve_from_index(index_name, search_term, meta=nil)
			index = indices.fetch(index_name)
			ids = index.fetch_ids(search_term, meta)
      if meta.respond_to?(:error_limit) && (limit = meta.error_limit) \
        && (size = ids.size) > limit.to_i
        error = OdbaResultLimitError.new
        error.limit = limit
        error.size = size
        error.index = index_name
        error.search_term = search_term
        error.meta = meta
        raise error
      end
			bulk_fetch(ids, nil)
		end
97741
public  <T> ESDatas<T> searchAll(String index,  int fetchSize ,Class<T> type) throws ElasticSearchException{
		return searchAll(index,  fetchSize ,(ScrollHandler<T>) null,type);
	}
1114650
def getitem(self, index, context=None):
        
        return _container_getitem(self, self.elts, index, context=context)
240269
function getNextPageofSearchResults() {
        var searchDeferred = $.Deferred();
        if (searchModel.allResultsAvailable) {
            return searchDeferred.resolve().promise();
        }
        _updateChangedDocs();
        FindUtils.notifyNodeSearchStarted();
        searchDomain.exec("nextPage")
            .done(function (rcvd_object) {
                FindUtils.notifyNodeSearchFinished();
                if (searchModel.results) {
                    var resultEntry;
                    for (resultEntry in rcvd_object.results ) {
                        if (rcvd_object.results.hasOwnProperty(resultEntry)) {
                            searchModel.results[resultEntry.toString()] = rcvd_object.results[resultEntry];
                        }
                    }
                } else {
                    searchModel.results = rcvd_object.results;
                }
                searchModel.fireChanged();
                searchDeferred.resolve();
            })
            .fail(function () {
                FindUtils.notifyNodeSearchFinished();
                console.log('node fails');
                FindUtils.setNodeSearchDisabled(true);
                searchDeferred.reject();
            });
        return searchDeferred.promise();
    }
780400
def OnSearch(self, event):
        """"""

        search_string = self.search.GetValue()

        if search_string not in self.search_history:
            self.search_history.append(search_string)
        if len(self.search_history) > 10:
            self.search_history.pop(0)

        self.menu = self.make_menu()
        self.search.SetMenu(self.menu)

        search_flags = self.search_options + ["FIND_NEXT"]

        post_command_event(self, self.FindMsg, text=search_string,
                           flags=search_flags)

        self.search.SetFocus()
1042295
def export_items(elastic_url, in_index, out_index, elastic_url_out=None,
                 search_after=False, search_after_value=None, limit=None,
                 copy=False):
    

    if not limit:
        limit = DEFAULT_LIMIT

    if search_after_value:
        search_after_value_timestamp = int(search_after_value[0])
        search_after_value_uuid = search_after_value[1]
        search_after_value = [search_after_value_timestamp, search_after_value_uuid]

    logging.info("Exporting items from %s/%s to %s", elastic_url, in_index, out_index)

    count_res = requests.get('%s/%s/_count' % (elastic_url, in_index))
    try:
        count_res.raise_for_status()
    except requests.exceptions.HTTPError:
        if count_res.status_code == 404:
            logging.error("The index does not exists: %s", in_index)
        else:
            logging.error(count_res.text)
        sys.exit(1)

    logging.info("Total items to copy: %i", count_res.json()['count'])

    # Time to upload the items with the correct mapping
    elastic_in = ElasticSearch(elastic_url, in_index)
    if not copy:
        # Create the correct mapping for the data sources detected from in_index
        ds_mapping = find_mapping(elastic_url, in_index)
    else:
        logging.debug('Using the input index mapping')
        ds_mapping = extract_mapping(elastic_url, in_index)

    if not elastic_url_out:
        elastic_out = ElasticSearch(elastic_url, out_index, mappings=ds_mapping)
    else:
        elastic_out = ElasticSearch(elastic_url_out, out_index, mappings=ds_mapping)

    # Time to just copy from in_index to our_index
    uid_field = find_uuid(elastic_url, in_index)
    backend = find_perceval_backend(elastic_url, in_index)
    if search_after:
        total = elastic_out.bulk_upload(fetch(elastic_in, backend, limit,
                                              search_after_value, scroll=False), uid_field)
    else:
        total = elastic_out.bulk_upload(fetch(elastic_in, backend, limit), uid_field)

    logging.info("Total items copied: %i", total)
1026934
function () {
            var selectedIndexes = this.getSelectedIndexes();
            var retVal = [];
            var items = this._data.items;
            for (var i = 0, length = selectedIndexes.length; i < length; i++) {
                retVal[i] = items[selectedIndexes[i]];
            }
            return retVal;
        }
508271
public <T> ESDatas<T> searchAllParallel(String index,ScrollHandler<T> scrollHandler,  Class<T> type,int thread) throws ElasticSearchException{
		return searchAllParallel(index,  DEFAULT_FETCHSIZE,scrollHandler,type,thread);
	}
1260662
def get_items_by_search(self, item_query, item_search):
        """"""
        # Implemented from azosid template for -
        # osid.resource.ResourceSearchSession.get_resources_by_search_template
        if not self._can('search'):
            raise PermissionDenied()
        return self._provider_session.get_items_by_search(item_query, item_search)
630289
def search(index, query, snippet_folder=SNIPPET_FOLDER, term_freq=term_freq):
    
    fallback_log = []
    code_list = []
    tokens = tokenize(query)
    tokens, abbr_log = abbr_expand(tokens)
    tokens, correct_log = correct(tokens, term_freq)
    tokens = lemmatize(tokens)
    tokens = filterout(tokens)
    while len(tokens) > 0: # Fallback mechanism
        code_list = fetch(index, tokens)
        if len(code_list) > 0:
            break
        tokens.sort(key=lambda tk:len(index.get(tk, [])))
        remove = tokens.pop()
        fallback_log.append(remove)
    snippets = get_snippets(code_list, snippet_folder)
    hints, hint_scores = get_hints(code_list, current_tokens=tokens)
    response = list(zip(code_list, snippets))
    response.sort(key=result_sort_key, reverse=True)

    # Count search_frequency
    if len(response) <= MAX_RESULT: # the respone can be shown in one page
        search_freq.update(code_list)
        with open(SEARCH_FREQ_JSON, 'w') as f:
            json.dump(search_freq, f, indent=2)

    return response, tokens, hints, hint_scores, \
           abbr_log, correct_log, fallback_log
160267
def find_by_index(self, cls, index_name, value):
        """"""
        return self.backend.find_by_index(cls, index_name, value)
495444
function instantSearch() {

    const q = $("#searchbox").val();
    if (q === '')
        return;

    const matcher = "/matcher?beginsWith=" + q;
    const request = host + matcher;

    console.debug(request);

    $.getJSON(request, '', {})
        .done(data => {

            $("#searchbox").autocomplete({
                source: data,
                select: (event) => {
                    event.stopPropagation();
                    $("#search").trigger("click");
                }
            });
        })
        .fail((d, textStatus, error) => {

            const err = d.status + " " + error + " -> message: " + d.responseText;
            bootstrapAlert.error(err);
            console.error(`Search request failed: \n ${err}`);
        });
}