Examples of LuceneIndexLocation


Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

      + ")#processSearch.Resolvables");

    LinkedHashMap<Document, Float> docs = objectToLinkedHashMapDocuments(searchResult
      .get(CRSearcher.RESULT_RESULT_KEY));

    LuceneIndexLocation idsLocation = LuceneIndexLocation.getIndexLocation(config);
    IndexAccessor indexAccessor = idsLocation.getAccessor();
    IndexReader reader = null;
    try {
      reader = indexAccessor.getReader(false);

      parsedQuery = parseHighlightQuery(request, reader, parsedQuery);
View Full Code Here

Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

    if (!subscribeToIndexFinished || !IndexingFinishedEvent.INDEXING_FINISHED_EVENT_TYPE.equals(event.getType())) {
      return;
    }

    Object obj = event.getData();
    LuceneIndexLocation callingLuceneLocation = (LuceneIndexLocation) callingIndexLocation;

    if (!callingLuceneLocation.equals(obj)) {
      return;
    }

    if (!reindexStrategy.skipReIndex(callingLuceneLocation)) {
      AbstractUpdateCheckerJob job = new DidyoumeanIndexJob(config, callingLuceneLocation, this);
      callingLuceneLocation.getQueue().addJob(job);
    }

  }
View Full Code Here

Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

    Searcher searcher;
    Analyzer analyzer;
    // Collect count + start hits
    int hits = count + start;  // we want to retreive the startcount (start) to endcount (hits)

    LuceneIndexLocation idsLocation = LuceneIndexLocation.getIndexLocation(config);

    // TODO: maybe we should make this configurable. Imho this should not be a problem if enabled by default as once a search
    // has been executed the Factory is opened and we only need to make sure that on shutdown it is released.
    boolean reopenIndexFactory = true;
    IndexAccessor indexAccessor = idsLocation.getAccessor(reopenIndexFactory);
    if (indexAccessor == null) {
      log.error("IndexAccessor is null. Search will not work.");
    }

    // Resources needed for faceted search
    TaxonomyAccessor taAccessor = null;
    TaxonomyReader taReader = null;
    IndexReader facetsIndexReader = null;
    IndexReader uniqueMimeTypesIndexReader = null;
   
    List<String> uniqueMimeTypes = null;
    if (retrieveUniqueMimeTypes) {
      // retrieve all possible file types
      uniqueMimeTypesIndexReader = indexAccessor.getReader(false);
      final TermEnum termEnum = uniqueMimeTypesIndexReader.terms(new Term(LUCENE_INDEX_MIMETYPE, ""));
      uniqueMimeTypes = new ArrayList<String>();
      while (termEnum.next() && termEnum.term().field().equals(LUCENE_INDEX_MIMETYPE)) {
        uniqueMimeTypes.add(termEnum.term().text());
      }
    }

    // get accessors and reader only if facets are activated
    if (facetsSearch.useFacets()) {
      facetsIndexReader = indexAccessor.getReader(false);
      taAccessor = idsLocation.getTaxonomyAccessor();
      taReader = taAccessor.getTaxonomyReader();
    }

    searcher = indexAccessor.getPrioritizedSearcher();
    Object userPermissionsObject = request.get(CRRequest.PERMISSIONS_KEY);
View Full Code Here

Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

    if (!subscribeToIndexFinished || !IndexingFinishedEvent.INDEXING_FINISHED_EVENT_TYPE.equals(event.getType())) {
      return;
    }

    Object obj = event.getData();
    LuceneIndexLocation callingLuceneLocation = (LuceneIndexLocation) callingIndexLocation;

    if (!callingLuceneLocation.equals(obj)) {
      return;
    }

    if (!reindexStrategy.skipReIndex(callingLuceneLocation)) {
      //clear SynonymIndexLocation everytime before a SynonymIndexJob is created.
      AbstractUpdateCheckerJob job = new SynonymIndexDeleteJob(config, callingLuceneLocation, this);
      callingLuceneLocation.getQueue().addJob(job);
      job = new SynonymIndexJob(config, callingLuceneLocation, this);
      callingLuceneLocation.getQueue().addJob(job);
    }

  }
View Full Code Here

Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

   * @throws IOException when theres a problem with accessing the Index
   */
  public final String includeSynonyms(String query) throws IOException {
   
    GenericConfiguration autoConf = (GenericConfiguration) config.get("synonymlocation");
    LuceneIndexLocation synonymLocation = LuceneIndexLocation
        .getIndexLocation(new CRConfigUtil(autoConf, "synonymlocation"));
   
   
    IndexAccessor ia = synonymLocation.getAccessor();
    Searcher synonymSearcher = ia.getPrioritizedSearcher();
    IndexReader synonymReader = ia.getReader(false);
   
   
    try {
View Full Code Here

Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

   */
  @Override
  protected final void indexCR(final IndexLocation indexLocation, final CRConfigUtil config) throws CRException {

    log.debug("Starting to clear index.");
    LuceneIndexLocation autocompleteLocation = autocompleter.getAutocompleteLocation();
    IndexAccessor ia = autocompleteLocation.getAccessor();
    IndexWriter writer = null;
    try {
      writer = ia.getWriter();
      writer.deleteAll();
      autocompleteLocation.resetIndexJobCreationTimes();
      autocompleteLocation.createReopenFile();
    } catch (IOException e) {
      log.error("Could not clear index", e);
    } finally {
      ia.release(writer);
    }
View Full Code Here

Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

  private synchronized void reIndex() throws IOException {
    UseCase ucReIndex = MonitorFactory.startUseCase("reIndex()");
    // build a dictionary (from the spell package)
    log.debug("Starting to reindex autocomplete index.");

    LuceneIndexLocation source = this.autocompleter.getSource();
    LuceneIndexLocation autocompleteLocation = this.autocompleter.getAutocompleteLocation();
    String autocompletefield = this.autocompleter.getAutocompletefield();

    IndexAccessor sia = source.getAccessor();
    IndexReader sourceReader = sia.getReader(false);
    LuceneDictionary dict = new LuceneDictionary(sourceReader, autocompletefield);
    IndexAccessor aia = autocompleteLocation.getAccessor();
    // IndexReader reader = aia.getReader(false);
    IndexWriter writer = aia.getWriter();

    try {
      writer.setMergeFactor(300);
      writer.setMaxBufferedDocs(150);
      // go through every word, storing the original word (incl. n-grams)
      // and the number of times it occurs
      // CREATE WORD LIST FROM SOURCE INDEX
      Map<String, Integer> wordsMap = new HashMap<String, Integer>();
      Iterator<String> iter = (Iterator<String>) dict.getWordsIterator();
      while (iter.hasNext()) {
        String word = iter.next();
        int len = word.length();
        if (len < 3) {
          continue; // too short we bail but "too long" is fine...
        }
        if (wordsMap.containsKey(word)) {
          throw new IllegalStateException("Lucene returned a bad word list");
        } else {
          // use the number of documents this word appears in
          wordsMap.put(word, sourceReader.docFreq(new Term(autocompletefield, word)));
        }
      }
      // DELETE OLD OBJECTS FROM INDEX
      writer.deleteAll();

      // UPDATE DOCUMENTS IN AUTOCOMPLETE INDEX
      for (String word : wordsMap.keySet()) {
        // ok index the word
        Document doc = new Document();
        doc.add(new Field(SOURCE_WORD_FIELD, word, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); // orig term
        doc.add(new Field(GRAMMED_WORDS_FIELD, word, Field.Store.YES, Field.Index.ANALYZED)); // grammed
        doc.add(new Field(COUNT_FIELD, Integer.toString(wordsMap.get(word)), Field.Store.YES,
            Field.Index.NOT_ANALYZED_NO_NORMS)); // count
        writer.addDocument(doc);
      }
      writer.optimize();
      autocompleteLocation.createReopenFile();
    } finally {

      sia.release(sourceReader, false);
      // close writer
View Full Code Here

Examples of com.gentics.cr.lucene.indexer.index.LuceneIndexLocation

    if (!subscribeToIndexFinished || !IndexingFinishedEvent.INDEXING_FINISHED_EVENT_TYPE.equals(event.getType())) {
      return;
    }

    Object obj = event.getData();
    LuceneIndexLocation callingLuceneLocation = (LuceneIndexLocation) callingIndexLocation;

    if (!callingLuceneLocation.equals(obj)) {
      return;
    }

    if (!reindexStrategy.skipReIndex(callingLuceneLocation)) {
      AbstractUpdateCheckerJob job = (AbstractUpdateCheckerJob) new AutocompleteIndexJob(config,
          callingLuceneLocation, this);
      callingLuceneLocation.getQueue().addJob(job);
    }

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.