Get the search index.
@param $create Boolean whether to create the index, if it does not exist (default: _true_)
@return An instance of ZendSearch/SearchIndexInterface or null
9350
private function getIndex($create = true) {
    if (!$this->index || $create) {
      $indexPath = $this->getIndexPath();

      $analyzer = new LuceneUtf8Analyzer();

      // add stop words filter
      $stopWords = $this->getStopWords();
      $stopWordsFilter = new StopWords($stopWords);
      $analyzer->addFilter($stopWordsFilter);

      Analyzer::setDefault($analyzer);
      Wildcard::setMinPrefixLength(0);
      QueryParser::setDefaultEncoding('UTF-8');
      QueryParser::setDefaultOperator(QueryParser::B_AND);

      try {
        $this->index = Lucene::open($indexPath);
        //$this->index->setMaxMergeDocs(5);
        //$this->index->setMergeFactor(5);
      }
      catch (\Exception $ex) {
        $this->index = $this->resetIndex();
      }
    }
    return $this->index;
  }
1295468
public function create(bool $recreate = false)
    {
        $this->getIndex()->create($this->_indexParams, $recreate);

        $mapping = new Mapping($this->getType());
        $mapping->setProperties($this->_mapping);
        $mapping->setSource(['enabled' => $this->_source]);
        $mapping->send();
    }
481264
public static function getOrCreateResultAt($index = 0)
    {
        $results = static::getResultAt($index);

        if (is_null($results)) {
            $results = static::makeResult()->attachAtIndex($index);
        }

        return $results;
    }
1304453
public function getSearchIndex($index)
    {
        return isset($this->search[$index]) ? $this->search[$index] : null;
    }
882162
public function createSearch( $default = false )
	{
		if( $default === true )
		{
			$object = $this->_createSearch( 'price' );
			$currencyid = $this->_getContext()->getLocale()->getCurrencyId();

			if( $currencyid !== null )
			{
				$expr = array(
					$object->compare( '==', 'price.currencyid', $currencyid ),
					$object->getConditions(),
				);

				$object->setConditions( $object->combine( '&&', $expr ) );
			}

			return $object;
		}

		return parent::createSearch();
	}
939949
public static function load() : SearchIndexStore
    {
        if (is_null(self::$instance)) {
            self::$instance = new SearchIndexStore(Connection::get());
        }

        return self::$instance;
    }
854747
public function getIndex() : ?string 
    {
        if ( ! $this->hasIndex()) {
            $this->setIndex($this->getDefaultIndex());
        }
        return $this->index;
    }
737729
function create($callback = false)
    {

        $index = new Index($this->index, $callback);

        $index->connection = $this->connection;

        return $index->create();
    }
976927
def get_or_create_index(self, paths=None, name=None, refresh=False):
        
        if not paths:
            paths = sys.path
        if not name:
            name = 'default'
        self._name = name

        idx_dir = get_cache_dir()
        idx_file = os.path.join(idx_dir, name + '.json')

        if os.path.exists(idx_file) and not refresh:
            with open(idx_file) as fd:
                self.deserialize(fd)
        else:
            self.build_index(paths)
            with open(idx_file, 'w') as fd:
                self.serialize(fd)

        return self
696982
public function get($index = 0, $field = null) {
        if ($this->performed) {
            if (is_numeric($index)) {
                $index = intval($index);
            } else if (is_string($index)) {
                $field = $index;
                $index = 0;
            } else {
                return null;
            }
        } else {
            if (is_array($index)) {
                return $this->where($index);
            }

            if (is_numeric($index)) {
                $index = intval($index);
            } else if (is_string($index)) {
                $field = $index;
                $this->field($field);
                $index = 0;
                $this->limit(0, 1);
            } else {
                $index = 0;
            }
            $this->select();
        }
        if (isset ($this->resultSets [ $index ])) {
            $row = $this->resultSets [ $index ];
            if ($field != null && isset ($row [ $field ])) {
                return $row [ $field ];
            }
            if ($field == null) {
                return $row;
            }
        }

        return null;
    }
1351313
public static function getDefaultSearchField()
    {
        if (count($this->_indices) == 0) {
            include_once 'Zend/Search/Lucene/Exception.php';
            throw new Zend_Search_Lucene_Exception('Indices list is empty');
        }

        $defaultSearchField = reset($this->_indices)->getDefaultSearchField();

        foreach ($this->_indices as $index) {
            if ($index->getDefaultSearchField() !== $defaultSearchField) {
                include_once 'Zend/Search/Lucene/Exception.php';
                throw new Zend_Search_Lucene_Exception('Indices have different default search field.');
            }
        }

        return $defaultSearchField;
    }
701475
public function currentRow($create = false)
    {
        $current = end($this->rows);
        if ($create && !$current) {
            $this->rows[] = $current = new SQLAssignmentRow();
        }
        return $current;
    }
602002
public static function get_request_creation_method_string($creation) {
        $creationmethods = self::get_request_creation_methods();
        if (!isset($creationmethods[$creation])) {
            throw new moodle_exception('errorinvalidrequestcreationmethod', 'tool_dataprivacy');
        }

        return $creationmethods[$creation];
    }
467852
public function getSearchResults($data = null, $form = null) {

		// Determine whether a search engine has been selected.

		$page = $this->data();
		$engine = $page->SearchEngine;
		$classes = Config::inst()->get(FulltextSearchable::class, 'searchable_classes');
		if(!$engine || (($engine !== 'Full-Text') && !ClassInfo::exists($engine)) || (($engine === 'Full-Text') && (!is_array($classes) || (count($classes) === 0)))) {

			// The search engine has not been selected.

			return $this->httpError(404);
		}

		// The analytics require the time taken.

		$time = microtime(true);

		// This is because the search form pulls from the request directly.

		if(!isset($data['Search'])) {
			$data['Search'] = '';
		}
		$search = $data['Search'];
		$request = $this->getRequest();
		$request->offsetSet('Search', $search);

		// Determine whether the remaining search parameters have been passed through.

		if(!isset($data['SortBy']) || !$data['SortBy']) {
			$data['SortBy'] = $page->SortBy;
		}
		if(!isset($data['SortDirection']) || !$data['SortDirection']) {
			$data['SortDirection'] = $page->SortDirection;
		}
		if(!isset($form)) {
			$form = $this->getForm($request);
		}

		// Instantiate some default templates.

		$templates = array(
			'ExtensibleSearch',
			'ExtensibleSearchPage',
			'Page'
		);

		// Determine the search engine that has been selected.

		if($engine !== 'Full-Text') {

			// The analytics require the time taken.

			$time = microtime(true);

			// Determine the search engine specific search results.

			$results = singleton($engine)->getSearchResults($data, $form, $page);

			// The search results format needs to be correct.

			if(!isset($results['Results'])) {
				$results = array(
					'Results' => $results
				);
			}

			// Determine the number of search results.

			$count = isset($results['Count']) ? (int)$results['Count'] : count($results['Results']);

			// Instantiate the search engine specific templates.

			$explode = explode('\\', $engine);
			$explode = end($explode);
			$templates = array_merge(array(
				"{$explode}_results",
				"{$explode}Page_results",
				'ExtensibleSearch_results',
				'ExtensibleSearchPage_results',
				'Page_results',
				$explode,
				"{$explode}Page"
			), $templates);
		}

		// Determine the full-text specific search results.

		else {

			// The paginated list needs to be manipulated, as filtering and sorting is not possible otherwise.

			$start = $request->getVar('start') ? (int)$request->getVar('start') : 0;
			$form->setPageLength(PHP_INT_MAX);

			// This is because the search form pulls from the request directly.

			$request->offsetSet('start', 0);
			$list = $form->getResults()->getList();

			// The search engine may only support limited hierarchy filtering for multiple sites.

			$filter = $page->SearchTrees()->column();
			if(count($filter) && (($hierarchy = $page->supports_hierarchy) || ClassInfo::exists(Multisites::class))) {

				// Apply the search trees filtering.

				$list = $list->filter($hierarchy ? 'ParentID' : 'SiteID', $filter);
			}

			// Apply custom filtering.

			$this->extend('updateFiltering', $list);

			// Apply the sorting.

			$list = $list->sort("{$data['SortBy']} {$data['SortDirection']}");

			// The paginated list needs to be instantiated again.

			$results = array(
				'Title' => _t('EXTENSIBLE_SEARCH.SEARCH_RESULTS', 'Search Results'),
				'Query' => $form->getSearchQuery(),
				'Results' => PaginatedList::create(
					$list
				)->setPageLength($page->ResultsPerPage)->setPageStart($start)->setTotalItems($count = $list->count())
			);

			// Instantiate the full-text specific templates.

			$templates = array_merge(array(
				'ExtensibleSearch_results',
				'ExtensibleSearchPage_results',
				'Page_results'
			), $templates);
		}

		// Determine the template to use.

		$this->extend('updateTemplates', $templates);
		$output = $this->customise($results)->renderWith($templates);
		$output->Count = $count;

		// Determine whether analytics are to be suppressed.

		if($search && ($request->getVar('analytics') !== 'false')) {

			// Update the search page specific analytics.

			$this->service->logSearch($search, $count, microtime(true) - $time, $engine, $page->ID);
		}

		// Display the search form results.

		return $output;
	}
962616
public function createSearch($query = '', $options = null, BuilderInterface $builder = null)
    {
        $search = new Search($this->getClient(), $builder);
        $search->addIndex($this);
        $search->setOptionsAndQuery($options, $query);

        return $search;
    }
656566
def create_index(index):
    """"""
    logger.info("Creating search index: '%s'", index)
    client = get_client()
    return client.indices.create(index=index, body=get_index_mapping(index))
1300091
private I_CmsSearchIndex getIndex() {

        I_CmsSearchIndex index = null;
        // get the configured index or the selected index
        if (isInitialCall()) {
            // the search form is in the initial state
            // get the configured index
            index = OpenCms.getSearchManager().getIndex(getSettings().getUserSettings().getWorkplaceSearchIndexName());
        } else {
            // the search form is not in the inital state, the submit button was used already or the
            // search index was changed already
            // get the selected index in the search dialog
            index = OpenCms.getSearchManager().getIndex(getJsp().getRequest().getParameter("indexName.0"));
        }
        return index;
    }