- subcur.execute("""SELECT word_id, word_token
- FROM word, (SELECT unnest(%s) as term) t
- WHERE word_token = make_standard_name(t.term)""",
- (terms,))
+ subcur.execute(""" SELECT word_id, word_token
+ FROM word, (SELECT unnest(%s::TEXT[]) as term) t
+ WHERE word_token = make_standard_name(t.term)
+ and class is null and country_code is null
+ and operator is null
+ UNION
+ SELECT word_id, word_token
+ FROM word, (SELECT unnest(%s::TEXT[]) as term) t
+ WHERE word_token = ' ' || make_standard_name(t.term)
+ and class is null and country_code is null
+ and operator is null
+ """,
+ (terms, words))