code: def test_multi_language():
      # Analyzer for English
      ana_eng = analysis.StemmingAnalyzer()
  
      # analyzer for Pig Latin
      def stem_piglatin(w):
          if w.endswith("ay"):
              w = w[:-2]
          return w
  
      ana_pig = analysis.StemmingAnalyzer(
          stoplist=["nday", "roay"], stemfn=stem_piglatin
      )
  
      # Dictionary mapping languages to analyzers
      analyzers = {"eng": ana_eng, "pig": ana_pig}
  
      # Fake documents
      corpus = [
          (u("eng"), u("Such stuff as dreams are made on")),
          (u("pig"), u("Otay ebay, roay otnay otay ebay")),
      ]
  
      schema = fields.Schema(
          content=fields.TEXT(stored=True), lang=fields.ID(stored=True)
      )
      ix = RamStorage().create_index(schema)
  
      with ix.writer() as w:
          for doclang, content in corpus:
              ana = analyzers[doclang]
              # "Pre-analyze" the field into token strings
              words = [token.text for token in ana(content)]
              # Note we store the original value but index the pre-analyzed words
              w.add_document(
                  lang=doclang, content=words, _stored_content=content
              )
  
      with ix.searcher() as s:
          schema = s.schema
  
          # Modify the schema to fake the correct analyzer for the language
          # we're searching in
          schema["content"].analyzer = analyzers["eng"]
  
          qp = qparser.QueryParser("content", schema)
          q = qp.parse("dreaming")
          r = s.search(q)
          assert len(r) == 1
          assert r[0]["content"] == "Such stuff as dreams are made on"
  
          schema["content"].analyzer = analyzers["pig"]
          qp = qparser.QueryParser("content", schema)
          q = qp.parse("otnay")
          r = s.search(q)
          assert len(r) == 1
          assert r[0]["content"] == "Otay ebay, roay otnay otay ebay"
  
imports: from __future__ import with_statement
  import random
  from collections import defaultdict
  from datetime import datetime
  import pytest
  from whoosh import analysis, fields, index, qparser, query, __version__
  from whoosh.compat import b, u, xrange, text_type, permutations
  from whoosh.filedb.filestore import RamStorage
  from whoosh.writing import IndexingError
  from whoosh.util.numeric import length_to_byte, byte_to_length
  from whoosh.util.testing import TempIndex, TempStorage
label_desc: Use image node_id 26 for calling a global function with example usage: test_multi_language() and returns: w