def count_out_of_date():
 es = es_utils.get_es()
 index_name = es_utils.write_index('default')
 settings = es.indices.get_settings(index_name).get(index_name, {}).get('settings', {})
 synonym_key_re = re.compile('index\\.analysis\\.filter\\.synonyms-.*\\.synonyms\\.\\d+')
 synonyms_in_es = set()
 for (key, val) in settings.items():
  if synonym_key_re.match(key):
   synonyms_in_es.add(val)
 synonyms_in_db = set((unicode(s) for s in Synonym.objects.all()))
 synonyms_to_add = (synonyms_in_db - synonyms_in_es)
 synonyms_to_remove = (synonyms_in_es - synonyms_in_db)
 if (synonyms_to_remove == set(['firefox => firefox'])):
  synonyms_to_remove = set()
 return (len(synonyms_to_add), len(synonyms_to_remove))

def count_out_of_date ( ) : es = es_utils . get_es ( ) index_name = es_utils . write_index ( 'default' ) settings = es . indices . get_settings ( index_name ) . get ( index_name , { } ) . get ( 'settings' , { } ) synonym_key_re = re . compile ( 'index\\.analysis\\.filter\\.synonyms-.*\\.synonyms\\.\\d+' ) synonyms_in_es = set ( ) for ( key , val ) in settings . items ( ) : if synonym_key_re . match ( key ) : synonyms_in_es . add ( val ) synonyms_in_db = set ( ( unicode ( s ) for s in Synonym . objects . all ( ) ) ) synonyms_to_add = ( synonyms_in_db - synonyms_in_es ) synonyms_to_remove = ( synonyms_in_es - synonyms_in_db ) if ( synonyms_to_remove == set ( [ 'firefox => firefox' ] ) ) : synonyms_to_remove = set ( ) return ( len ( synonyms_to_add ) , len ( synonyms_to_remove ) )
count number of synonyms that differ between the database and es .