mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
Merge pull request #583 from kaedroho/elasticsearch-asciifolding
Enabled ASCIIFolding in Elasticsearch backend
This commit is contained in:
commit
7c69dd2616
@ -510,12 +510,12 @@ class ElasticSearch(BaseSearch):
|
|||||||
'ngram_analyzer': {
|
'ngram_analyzer': {
|
||||||
'type': 'custom',
|
'type': 'custom',
|
||||||
'tokenizer': 'lowercase',
|
'tokenizer': 'lowercase',
|
||||||
'filter': ['ngram']
|
'filter': ['asciifolding', 'ngram']
|
||||||
},
|
},
|
||||||
'edgengram_analyzer': {
|
'edgengram_analyzer': {
|
||||||
'type': 'custom',
|
'type': 'custom',
|
||||||
'tokenizer': 'lowercase',
|
'tokenizer': 'lowercase',
|
||||||
'filter': ['edgengram']
|
'filter': ['asciifolding', 'edgengram']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'tokenizer': {
|
'tokenizer': {
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from wagtail.tests.utils import unittest
|
from wagtail.tests.utils import unittest
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
@ -65,6 +68,28 @@ class TestElasticSearchBackend(BackendTests, TestCase):
|
|||||||
self.assertEqual(len(results), 1)
|
self.assertEqual(len(results), 1)
|
||||||
self.assertEqual(results[0].id, obj.id)
|
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):
|
class TestElasticSearchQuery(TestCase):
|
||||||
def assertDictEqual(self, a, b):
|
def assertDictEqual(self, a, b):
|
||||||
|
Loading…
Reference in New Issue
Block a user