I have a Postgres 9.3 database where users are mostly searching for locations by a combination of name and/or address (or fragments of).
An example of an address would be “123 8th st”.
I’ve been able to setup a synonym dictionary that allows users to find such an address with “123 8th street”, but I can’t seem to get it to do the same for ordinals. That is, I want a search for “123 8 street” (etc) to be able to find this address.
I’m using the following code:
CREATE TEXT SEARCH CONFIGURATION my_app_english (
COPY = english
);
CREATE TEXT SEARCH DICTIONARY my_app_synonyms (
TEMPLATE = synonym,
SYNONYMS = my_app_synonyms
);
ALTER TEXT SEARCH CONFIGURATION my_app_english
ALTER MAPPING FOR asciiword
WITH my_app_synonyms, english_stem;
And the synonym file had lines like:
1st 1
2nd 2
3rd 3
4th 4
5th 5
...
How can I make this full text search match “8th” when the user searches for “8″?
I suspect the token type is the issue, but am not sure how I can consistently treat the token with the ordinal like that without.