Skip to content

Commit cddc4db

Browse files
committed
No need to store fields separately in elasticsearch
That will justlead to fields being stored once - as part of _source as well as in separate index that would never be used by haystack (would be used only in special cases when requesting just that field, which can be, with minimal overhead, still just extracted from the _source as it is).
1 parent 9fdf698 commit cddc4db

File tree

2 files changed

+19
-31
lines changed

2 files changed

+19
-31
lines changed

haystack/backends/elasticsearch_backend.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,6 @@ def build_schema(self, fields):
624624
if field_class.document is True:
625625
content_field_name = field_class.index_fieldname
626626

627-
# The docs claim nothing is needed for multivalue...
628-
# if field_class.is_multivalued:
629-
# field_data['multi_valued'] = 'true'
630-
631-
if field_class.stored:
632-
field_mapping['store'] = 'yes'
633-
634627
# Do this last to override `text` fields.
635628
if field_mapping['type'] == 'string':
636629
if field_class.indexed is False or hasattr(field_class, 'facet_for'):

tests/elasticsearch_tests/tests/test_elasticsearch_backend.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,10 @@ def test_build_schema(self):
440440
self.assertEqual(content_field_name, 'text')
441441
self.assertEqual(len(mapping), 4)
442442
self.assertEqual(mapping, {
443-
'text': {'type': 'string', 'analyzer': 'snowball', 'store': 'yes'},
444-
'pub_date': {'store': 'yes', 'type': 'date'},
445-
'name': {'type': 'string', 'analyzer': 'snowball', 'store': 'yes'},
446-
'name_exact': {'index': 'not_analyzed', 'store': 'yes', 'type': 'string'}
443+
'text': {'type': 'string', 'analyzer': 'snowball'},
444+
'pub_date': {'type': 'date'},
445+
'name': {'type': 'string', 'analyzer': 'snowball'},
446+
'name_exact': {'index': 'not_analyzed', 'type': 'string'}
447447
})
448448

449449
ui = UnifiedIndex()
@@ -452,21 +452,21 @@ def test_build_schema(self):
452452
self.assertEqual(content_field_name, 'text')
453453
self.assertEqual(len(mapping), 15)
454454
self.assertEqual(mapping, {
455-
'name': {'type': 'string', 'analyzer': 'snowball', 'store': 'yes'},
456-
'is_active_exact': {'store': 'yes', 'type': 'boolean'},
457-
'created': {'store': 'yes', 'type': 'date'},
458-
'post_count': {'store': 'yes', 'type': 'long'},
459-
'created_exact': {'store': 'yes', 'type': 'date'},
460-
'sites_exact': {'index': 'not_analyzed', 'store': 'yes', 'type': 'string'},
461-
'is_active': {'store': 'yes', 'type': 'boolean'},
462-
'sites': {'type': 'string', 'analyzer': 'snowball', 'store': 'yes'},
463-
'post_count_i': {'store': 'yes', 'type': 'long'},
464-
'average_rating': {'store': 'yes', 'type': 'float'},
465-
'text': {'type': 'string', 'analyzer': 'snowball', 'store': 'yes'},
466-
'pub_date_exact': {'type': 'date', 'store': 'yes'},
467-
'name_exact': {'index': 'not_analyzed', 'store': 'yes', 'type': 'string'},
468-
'pub_date': {'store': 'yes', 'type': 'date'},
469-
'average_rating_exact': {'store': 'yes', 'type': 'float'}
455+
'name': {'type': 'string', 'analyzer': 'snowball'},
456+
'is_active_exact': {'type': 'boolean'},
457+
'created': {'type': 'date'},
458+
'post_count': {'type': 'long'},
459+
'created_exact': {'type': 'date'},
460+
'sites_exact': {'index': 'not_analyzed', 'type': 'string'},
461+
'is_active': {'type': 'boolean'},
462+
'sites': {'type': 'string', 'analyzer': 'snowball'},
463+
'post_count_i': {'type': 'long'},
464+
'average_rating': {'type': 'float'},
465+
'text': {'type': 'string', 'analyzer': 'snowball'},
466+
'pub_date_exact': {'type': 'date'},
467+
'name_exact': {'index': 'not_analyzed', 'type': 'string'},
468+
'pub_date': {'type': 'date'},
469+
'average_rating_exact': {'type': 'float'}
470470
})
471471

472472
def test_verify_type(self):
@@ -1071,26 +1071,21 @@ def test_build_schema(self):
10711071
'name_auto': {
10721072
'type': 'string',
10731073
'analyzer': 'edgengram_analyzer',
1074-
'store': 'yes'
10751074
},
10761075
'text': {
10771076
'type': 'string',
10781077
'analyzer': 'snowball',
1079-
'store': 'yes'
10801078
},
10811079
'pub_date': {
1082-
'store': 'yes',
10831080
'type': 'date'
10841081
},
10851082
'name': {
10861083
'type': 'string',
10871084
'analyzer': 'snowball',
1088-
'store': 'yes'
10891085
},
10901086
'text_auto': {
10911087
'type': 'string',
10921088
'analyzer': 'edgengram_analyzer',
1093-
'store': 'yes'
10941089
}
10951090
})
10961091

0 commit comments

Comments
 (0)