test2.py 493 B

123456789101112131415161718192021222324252627
  1. #
  2. # $Id$
  3. #
  4. from sphinxapi import *
  5. import sys
  6. docs = ['this is my test text to be highlighted','this is another test text to be highlighted']
  7. words = 'test text'
  8. index = 'test1'
  9. opts = {'before_match':'<b>', 'after_match':'</b>', 'chunk_separator':' ... ', 'limit':400, 'around':15}
  10. cl = SphinxClient()
  11. res = cl.BuildExcerpts(docs, index, words, opts)
  12. if not res:
  13. print 'ERROR:', cl.GetLastError()
  14. else:
  15. n = 0
  16. for entry in res:
  17. n += 1
  18. print 'n=%d, res=%s' % (n, entry)
  19. #
  20. # $Id$
  21. #