mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 01:03:11 +00:00
Merge pull request #583 from kaedroho/elasticsearch-asciifolding
Enabled ASCIIFolding in Elasticsearch backend
This commit is contained in:
commit
7c69dd2616
2 changed files with 27 additions and 2 deletions
|
|
@ -510,12 +510,12 @@ class ElasticSearch(BaseSearch):
|
|||
'ngram_analyzer': {
|
||||
'type': 'custom',
|
||||
'tokenizer': 'lowercase',
|
||||
'filter': ['ngram']
|
||||
'filter': ['asciifolding', 'ngram']
|
||||
},
|
||||
'edgengram_analyzer': {
|
||||
'type': 'custom',
|
||||
'tokenizer': 'lowercase',
|
||||
'filter': ['edgengram']
|
||||
'filter': ['asciifolding', 'edgengram']
|
||||
}
|
||||
},
|
||||
'tokenizer': {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from wagtail.tests.utils import unittest
|
||||
import datetime
|
||||
import json
|
||||
|
|
@ -65,6 +68,28 @@ class TestElasticSearchBackend(BackendTests, TestCase):
|
|||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(results[0].id, obj.id)
|
||||
|
||||
def test_ascii_folding(self):
|
||||
# Reset the index
|
||||
self.backend.reset_index()
|
||||
self.backend.add_type(models.SearchTest)
|
||||
self.backend.add_type(models.SearchTestChild)
|
||||
|
||||
# Add some test data
|
||||
obj = models.SearchTest()
|
||||
obj.title = "Ĥéỻø"
|
||||
obj.live = True
|
||||
obj.save()
|
||||
self.backend.add(obj)
|
||||
|
||||
# Refresh the index
|
||||
self.backend.refresh_index()
|
||||
|
||||
# Search and check
|
||||
results = self.backend.search("Hello", models.SearchTest.objects.all())
|
||||
|
||||
self.assertEqual(len(results), 1)
|
||||
self.assertEqual(results[0].id, obj.id)
|
||||
|
||||
|
||||
class TestElasticSearchQuery(TestCase):
|
||||
def assertDictEqual(self, a, b):
|
||||
|
|
|
|||
Loading…
Reference in a new issue