예제 #1
0
 def test_contral_search_analyzer(self):
     """Control test that the default ngram search analyzer is None"""
     back_class = backends.ConfigurableElasticBackend(
         'default', URL="http://localhost:9200", INDEX_NAME="")
     text_field = HaystackEdgeNgramField(document=True,
                                         use_template=True,
                                         index_fieldname='body')
     # build_schema is passed a SortedDict of search index fields keyed by
     # field name
     schema = back_class.build_schema({'body': text_field})
     self.assertFalse('search_analyzer' in schema[1]['body'])
예제 #2
0
 def test_custom_search_analyzer(self):
     """Ensure custom analyzer used for fields"""
     back_class = backends.ConfigurableElasticBackend(
         'default', URL="http://localhost:9200", INDEX_NAME="")
     text_field = HaystackEdgeNgramField(document=True,
                                         use_template=True,
                                         index_fieldname='body')
     # build_schema is passed a SortedDict of search index fields keyed by
     # field name
     schema = back_class.build_schema({'body': text_field})
     self.assertTrue('search_analyzer' in schema[1]['body'])
     self.assertEqual("stop", schema[1]['body']['search_analyzer'])