title: What are the best practices for combining analyzers in Lucene?
body: <p>I have a situation where I'm using a StandardAnalyzer in Lucene to index text strings as follows:</p>
  
  <pre><code>public void indexText(String suffix, boolean includeStopWords)  {        
      StandardAnalyzer analyzer = null;
  
  
      if (includeStopWords) {
          analyzer = new StandardAnalyzer(Version.LUCENE_30);
      }
      else {
  
          // Get Stop_Words to exclude them.
          Set&lt;String&gt; stopWords = (Set&lt;String&gt;) Stop_Word_Listener.getStopWords();      
          analyzer = new StandardAnalyzer(Version.LUCENE_30, stopWords);
      }
  
      try {
  
          // Index text.
          Directory index = new RAMDirectory();
          IndexWriter w = new IndexWriter(index, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);            
          this.addTextToIndex(w, this.getTextToIndex());
          w.close();
  
          // Read index.
          IndexReader ir = IndexReader.open(index);
          Text_TermVectorMapper ttvm = new Text_TermVectorMapper();
  
          int docId = 0;
  
          ir.getTermFreqVector(docId, PropertiesFile.getProperty(text), ttvm);
  
          // Set output.
          this.setWordFrequencies(ttvm.getWordFrequencies());
          w.close();
      }
      catch(Exception ex) {
          logger.error("Error message\n", ex);
      }
  }
  
  private void addTextToIndex(IndexWriter w, String value) throws IOException {
      Document doc = new Document();
      doc.add(new Field(text), value, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.YES));
      w.addDocument(doc);
  }
  </code></pre>
  
  <p>Which works perfectly well but I would like to combine this with stemming using a SnowballAnalyzer as well. </p>
  
  <p>This class also has two instance variables shown in a constructor below:</p>
  
  <pre><code>public Text_Indexer(String textToIndex) {
      this.textToIndex = textToIndex;
      this.wordFrequencies = new HashMap&lt;String, Integer&gt;();
  }
  </code></pre>
  
  <p>Can anyone tell me how best to achieve this with the code above?</p>
  
  <p>Thanks</p>
  
  <p>Mr Morgan.</p>