# HG changeset patch # User ymh # Date 1368447757 -7200 # Node ID 6ab716dd58f8e06a4f0d5bd323da726a5836d573 # Parent 54ef33bb4065d2a93bd7fc49d22b07335e581677 merge correction diff -r 54ef33bb4065 -r 6ab716dd58f8 .settings/org.eclipse.core.resources.prefs --- a/.settings/org.eclipse.core.resources.prefs Sat May 11 23:09:05 2013 +0200 +++ b/.settings/org.eclipse.core.resources.prefs Mon May 13 14:22:37 2013 +0200 @@ -1,4 +1,3 @@ -#Mon Apr 08 17:07:34 CEST 2013 eclipse.preferences.version=1 encoding//src/ldt/ldt/core/migrations/0001_initial.py=utf-8 encoding//src/ldt/ldt/core/migrations/0002_auto__del_owner.py=utf-8 @@ -38,6 +37,7 @@ encoding//src/ldt/ldt/ldt_utils/migrations/0026_set_relative_ldtproject.py=utf-8 encoding//src/ldt/ldt/ldt_utils/views/json.py=utf-8 encoding//src/ldt/ldt/management/commands/synciri.py=utf-8 +encoding//src/ldt/ldt/management/commands/updateiriurlinprojects.py=utf-8 encoding//src/ldt/ldt/management/utils.py=utf-8 encoding//src/ldt/ldt/test/test_runner.py=utf-8 encoding//src/ldt/ldt/text/migrations/0001_initial.py=utf-8 diff -r 54ef33bb4065 -r 6ab716dd58f8 src/ldt/ldt/indexation/backends/elasticsearch_backend.py --- a/src/ldt/ldt/indexation/backends/elasticsearch_backend.py Sat May 11 23:09:05 2013 +0200 +++ b/src/ldt/ldt/indexation/backends/elasticsearch_backend.py Mon May 13 14:22:37 2013 +0200 @@ -60,70 +60,7 @@ return kwargs - def _process_results(self, raw_results, highlight=False, result_class=None): - from haystack import connections - results = [] - hits = raw_results.get('hits', {}).get('total', 0) - facets = {} - spelling_suggestion = None - - if result_class is None: - result_class = SearchResult - - if 'facets' in raw_results: - facets = { - 'fields': {}, - 'dates': {}, - 'queries': {}, - } - - for facet_fieldname, facet_info in raw_results['facets'].items(): - if facet_info.get('_type', 'terms') == 'terms': - facets['fields'][facet_fieldname] = [(individual['term'], individual['count']) for individual in facet_info['terms']] - elif facet_info.get('_type', 'terms') == 'date_histogram': - # Elasticsearch provides UTC timestamps with an extra three - # decimals of precision, which datetime barfs on. - facets['dates'][facet_fieldname] = [(datetime.datetime.utcfromtimestamp(individual['time'] / 1000), individual['count']) for individual in facet_info['entries']] - elif facet_info.get('_type', 'terms') == 'query': - facets['queries'][facet_fieldname] = facet_info['count'] - - unified_index = connections[self.connection_alias].get_unified_index() - indexed_models = unified_index.get_indexed_models() - - for raw_result in raw_results.get('hits', {}).get('hits', []): - source = raw_result['_source'] - app_label, model_name = source[DJANGO_CT].split('.') - additional_fields = {} - model = get_model(app_label, model_name) - - if model and model in indexed_models: - for key, value in source.items(): - index = unified_index.get_index(model) - string_key = str(key) - - if string_key in index.fields and hasattr(index.fields[string_key], 'convert'): - additional_fields[string_key] = index.fields[string_key].convert(value) - else: - additional_fields[string_key] = self.conn.to_python(value) - - del(additional_fields[DJANGO_CT]) - del(additional_fields[DJANGO_ID]) - - if 'highlight' in raw_result: - additional_fields['highlighted'] = raw_result['highlight'] - - result = result_class(app_label, model_name, source[DJANGO_ID], raw_result['_score'], **additional_fields) - results.append(result) - else: - hits -= 1 - - return { - 'results': results, - 'hits': hits, - 'facets': facets, - 'spelling_suggestion': spelling_suggestion, - } - + def remove(self, obj_or_string, commit=True): if not self.setup_complete: