Package org.apache.lucene.analysis.standard

Examples of org.apache.lucene.analysis.standard.StandardAnalyzer


      {
         Map<String,Float> boostPerField = new HashMap<String,Float>();
         boostPerField.put( "title:en", 4f );
         boostPerField.put( "body:en", 1f );
         String[] productFields = {"title:en", "body:en"};
         QueryParser parser = new MultiFieldQueryParser(productFields, new StandardAnalyzer(), boostPerField);
         parser.setAllowLeadingWildcard(true);
         org.apache.lucene.search.Query luceneQuery;
         try
         {
            luceneQuery = parser.parse(searchPattern);
View Full Code Here


        boostPerField.put("description", 2f);
        boostPerField.put("actors.name", 2f);
        boostPerField.put("categories.name", 0.5f);

        String[] productFields = {"title", "description", "actors.name", "categories.name"};
        QueryParser parser = new MultiFieldQueryParser(productFields, new StandardAnalyzer(), boostPerField);
        parser.setAllowLeadingWildcard(true);
        org.apache.lucene.search.Query luceneQuery;
        luceneQuery = parser.parse(searchQuery);
        return ( (FullTextEntityManager) em ).createFullTextQuery(luceneQuery, Product.class);
    }
View Full Code Here

        // 3. Close reader
        indexReader.close();
        directory.close();
       
        // 4. open writer
        IndexWriter indexWriter = new IndexWriter(directory, new StandardAnalyzer(Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.UNLIMITED);
        indexWriter.setMergeFactor(INDEX_MERGE_FACTOR); //for better performance
        // 5. Add new Document
        for (int i = 0; i < updateCopy.size(); i++) {
          Document document = updateCopy.get(i);
          log.info("addDocument:" + document);
View Full Code Here

        Dictionary authorDictionary = new LuceneDictionary(indexReader, OlatDocument.AUTHOR_FIELD_NAME);
        authorSpellChecker.indexDictionary(authorDictionary);
       
        // Merge all part spell indexes (content,title etc.) to one common spell index
        Directory spellIndexDirectory = FSDirectory.open(spellDictionaryFile);//true
        IndexWriter merger = new IndexWriter(spellIndexDirectory, new StandardAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
        Directory[] directories = { contentSpellIndexDirectory, titleSpellIndexDirectory, descriptionSpellIndexDirectory, authorSpellIndexDirectory};
        merger.addIndexesNoOptimize(directories);
        merger.optimize();
        merger.close();
        spellChecker = new SpellChecker(spellIndexDirectory);
View Full Code Here

   * [used by spring]
   * @param indexPath the absolute file-path to search index directory.
   */
  public void setIndexPath(String indexPath) {
    this.indexPath = indexPath;   
    analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
    try {
      createIndexSearcher(indexPath);
      checkIsIndexUpToDate();
    } catch (IOException e) {
      log.info("Can not create IndexSearcher at startup");
View Full Code Here

   */
  private void doIndex() throws InterruptedException{
    try {
      File tempIndexDir = new File(tempIndexPath);
      Directory indexPath = FSDirectory.open(new File(tempIndexDir, "main"));
      Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
      indexWriter = new IndexWriter(indexPath, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
      indexWriter.deleteAll();
      indexWriter.setMergeFactor(INDEX_MERGE_FACTOR); //for better performance
      // Create IndexWriterWorker
      log.info("Running with " + numberIndexWriter + " IndexerWriterWorker");
View Full Code Here

    return SearchResults.EMPTY_SEARCH_RESULTS;
  }
 
  protected Set<String> getHighlightWords(String searchString) {
    try {
      Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
      TokenStream stream = analyzer.tokenStream("content", new StringReader(searchString));
      TermAttribute termAtt = (TermAttribute) stream.addAttribute(TermAttribute.class);
      for (boolean next = stream.incrementToken(); next; next = stream.incrementToken()) {
        String term = termAtt.term();
        if(log.isDebug()) log.debug(term);
      }
View Full Code Here

    this.id = id;
    this.fullIndexer = fullIndexer;
    try {
      File indexPartFile = new File(tempIndexDir, "part" + id);
      Directory indexPartDirectory = FSDirectory.open(indexPartFile);
      indexWriter = new IndexWriter(indexPartDirectory, new StandardAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
      indexWriter.deleteAll();
    } catch (IOException e) {
      log.warn("Can not create IndexWriter");
    }
  }
View Full Code Here

        try
        {
            Date start = new Date();

            writer = new IndexWriter(index, new StandardAnalyzer(), create);

            if (!create)
            {                 // delete stale docs
                deleting = true;
                indexDocs(root, index, create);
View Full Code Here

    public void testIndexWriterLockRelease() throws IOException {
        Directory dir = newFSDirectory(this.__test_dir);
        try {
          new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
              new StandardAnalyzer(TEST_VERSION_CURRENT))
          .setOpenMode(OpenMode.APPEND));
        } catch (FileNotFoundException e) {
            try {
              new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT,
                  new StandardAnalyzer(TEST_VERSION_CURRENT))
              .setOpenMode(OpenMode.APPEND));
            } catch (FileNotFoundException e1) {
            }
        } finally {
          dir.close();
View Full Code Here

TOP

Related Classes of org.apache.lucene.analysis.standard.StandardAnalyzer

Copyright © 2018 www.massapicom. 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.