Indexes an item that is queued for indexing into the search engine.
556825
public function indexQueuedItem(QueueMessage $message)
    {
        $log = $this->getLogger();
        $context = array(
            'engine' => get_class($this->_searchEngine),
            'item' => $message->getBody(),
        );

        // Load the source data form the message. The message usually contains a
        // unique identifier in the body. Skip processing if false is returned
        // as the source data.
        $collection = $message->getCollection();
        $data = $collection->loadSourceData($message);

        if ($data) {
            $context['collection'] = $collection->getId();
            $log->debug('Data fetched from source', $context);

            // Build an index document from the source data.
            $document = $this->_searchEngine->newDocument($this);
            $collection->buildDocument($document, $data);
            $log->debug('Document prepared for indexing', $context);

            // Index the document, sandwich indexing with events.
            $event = new IndexDocumentEvent($this, $document, $data);
            $this->dispatchEvent(SearchEvents::DOCUMENT_PRE_INDEX, $event);
            $this->_searchEngine->indexDocument($collection, $document);
            $this->dispatchEvent(SearchEvents::DOCUMENT_POST_INDEX, $event);

            $log->debug('Document processed for indexing', $context);

        } else {
            $log->critical('Data could not be loaded from source', $context);
        }
    }
830757
def paginated_retrieval(methodname, itemtype):
    """"""
    return compose(
        reusable,
        basic_interaction,
        map_yield(partial(_params_as_get, methodname)),
    )
552653
private void indexQuery(
      long index,
      long timestamp,
      RaftSession session,
      PrimitiveOperation operation,
      CompletableFuture<OperationResult> future) {
    // If the query index is greater than the session's last applied index, queue the request for handling once the
    // state machine is caught up.
    if (index > currentIndex) {
      log.trace("Registering query with index " + index + " > " + currentIndex);
      session.registerIndexQuery(index, () -> applyQuery(timestamp, session, operation, future));
    } else {
      applyQuery(timestamp, session, operation, future);
    }
  }
119021
public function runIndexing()
    {
        $iterator = $this->getResourceIterator();
        $indexIterator = new IndexIterator($iterator);
        $indexIterator->setServiceLocator($this->getServiceLocator());
        $searchService = $this->getServiceLocator()->get(Search::SERVICE_ID);
        $result = $searchService->index($indexIterator);
        $this->logDebug($result . ' resources have been indexed by ' . static::class);
        return $result;
    }
1184569
private void indexArrayStore(int e, int i)
    {
        if (valueIndexStore.length < e)
        {
            int oldLength = valueIndexStore.length;
            valueIndexStore = Arrays.copyOf(valueIndexStore, e + 2);
            Arrays.fill(valueIndexStore, oldLength, valueIndexStore.length, -1);
        }
        valueIndexStore[e] = i;
    }
347424
def index():
    """"""
    page = request.values.get('page', 1, type=int)
    size = request.values.get('size', 2, type=int)
    search = ExampleSearch()[(page - 1) * size:page * size]
    if 'q' in request.values:
        search = search.query(QueryString(query=request.values.get('q')))

    search = search.sort(
        request.values.get('sort', 'title')
    )
    search = ExampleSearch.faceted_search(search=search)
    results = search.execute().to_dict()
    return jsonify({'hits': results.get('hits')})
740798
protected function getIndexQueueItem()
    {
        /** @var $indexQueue Queue */
        $indexQueue = GeneralUtility::makeInstance(Queue::class);
        $indexQueueItem = $indexQueue->getItem($this->request->getParameter('item'));
        return $indexQueueItem;
    }
12160
def start_index(self):
        """"""
        paginator = self.paginator
        # Special case, return zero if no items.
        if paginator.count == 0:
            return 0
        elif self.number == 1:
            return 1
        return (
            (self.number - 2) * paginator.per_page + paginator.first_page + 1)
1222415
private void fillQueue(QueueItem item, Integer minStartPosition,
      Integer maxStartPosition, Integer minEndPosition) throws IOException {
    int newStartPosition;
    int newEndPosition;
    Integer firstRetrievedPosition = null;
    // remove everything below minStartPosition
    if ((minStartPosition != null) && (item.lowestPosition != null)
        && (item.lowestPosition < minStartPosition)) {
      item.del((minStartPosition - 1));
    }
    // fill queue
    while (!item.noMorePositions) {
      boolean doNotCollectAnotherPosition;
      doNotCollectAnotherPosition = item.filledPosition
          && (minStartPosition == null) && (maxStartPosition == null);
      doNotCollectAnotherPosition |= item.filledPosition
          && (maxStartPosition != null) && (item.lastRetrievedPosition != null)
          && (maxStartPosition < item.lastRetrievedPosition);
      if (doNotCollectAnotherPosition) {
        return;
      } else {
        // collect another full position
        firstRetrievedPosition = null;
        while (!item.noMorePositions) {
          newStartPosition = item.sequenceSpans.spans.nextStartPosition();
          if (newStartPosition == NO_MORE_POSITIONS) {
            if (!item.queue.isEmpty()) {
              item.filledPosition = true;
              item.lastFilledPosition = item.lastRetrievedPosition;
            }
            item.noMorePositions = true;
            return;
          } else if ((minStartPosition != null)
              && (newStartPosition < minStartPosition)) {
            // do nothing
          } else {
            newEndPosition = item.sequenceSpans.spans.endPosition();
            if ((minEndPosition == null) || (newEndPosition >= minEndPosition
                - ignoreItem.getMinStartPosition(docId, newEndPosition))) {
              item.add(newStartPosition, newEndPosition);
              if (firstRetrievedPosition == null) {
                firstRetrievedPosition = newStartPosition;
              } else if (!firstRetrievedPosition.equals(newStartPosition)) {
                break;
              }
            }
          }
        }
      }
    }
  }
700620
protected void processQueue() {
        try {
            QueueItem item = queue.take();
            client.addMultipleCounterDataPoints(item.tenantId, item.data);
        } catch (InterruptedException e) {
            // TODO better logging of this unlikely error
            e.printStackTrace();
            return;
        }
    }
1236768
def run
      response = Response.new request(:search, @queue)

      results = @queue.collect do
        result = {
          :matches         => [],
          :fields          => [],
          :attributes      => {},
          :attribute_names => [],
          :words           => {}
        }

        result[:status] = response.next_int
        case result[:status]
        when Statuses[:warning]
          result[:warning] = response.next
        when Statuses[:error]
          result[:error] = response.next
          next result
        end

        result[:fields] = response.next_array

        attributes = response.next_int
        attributes.times do
          attribute_name = response.next
          type           = response.next_int

          result[:attributes][attribute_name] = type
          result[:attribute_names] << attribute_name
        end

        result_attribute_names_and_types = result[:attribute_names].
          inject([]) { |array, attr| array.push([ attr, result[:attributes][attr] ]) }

        matches   = response.next_int
        is_64_bit = response.next_int

        result[:matches] = (0...matches).map do |i|
          doc = is_64_bit > 0 ? response.next_64bit_int : response.next_int
          weight = response.next_int

          current_match_attributes = {}

          result_attribute_names_and_types.each do |attr, type|
            current_match_attributes[attr] = attribute_from_type(type, response)
          end

          {:doc => doc, :weight => weight, :index => i, :attributes => current_match_attributes}
        end

        result[:total] = response.next_int.to_i || 0
        result[:total_found] = response.next_int.to_i || 0
        result[:time] = ('%.3f' % (response.next_int / 1000.0)).to_f || 0.0

        words = response.next_int
        words.times do
          word = response.next
          docs = response.next_int
          hits = response.next_int
          result[:words][word] = {:docs => docs, :hits => hits}
        end

        result
      end

      @queue.clear
      results
    rescue Riddle::OutOfBoundsError => error
      raise error
    rescue => original
      error = ResponseError.new original.message
      error.original = original
      raise error
    end
640285
def purge_queue():
    """"""
    def action(queue):
        queue.purge()
        click.secho('Indexing queue has been purged.', fg='green')
        return queue
    return action
1062900
public void enqueue(T item) {
        queue[head] = item;
        head++;
        size++;
        if (head == queue.length) head = 0;
    }
462802
void add(T item) {
    int i = nextIndex.getAndIncrement() % data.length();
    data.set(i, item);
  }
738828
def process_item(self, item, spider):  # pylint: disable=unused-argument
        
        url = self.clean_url(item["url"])

        if self.is_sequence_start_page(url):
            url = url.parent

        if url in self.urls_seen:
            raise DropItem(u"Dropping duplicate url {url}".format(url=item["url"]))
        else:
            self.urls_seen.add(url)
            return item
943126
def sort(self, search):
        
        if self._sort:
            search = search.sort(*self._sort)
        return search
246047
def put(index_name, doc_type, identifier, body, force, verbose):
    """"""
    result = current_search_client.index(
        index=index_name,
        doc_type=doc_type or index_name,
        id=identifier,
        body=json.load(body),
        op_type='index' if force or identifier is None else 'create',
    )
    if verbose:
        click.echo(json.dumps(result))