diff --git a/contrib/pg_trgm/data/trgm2.data b/contrib/pg_trgm/data/trgm2.data new file mode 100644 index 0000000000..664e079fec --- /dev/null +++ b/contrib/pg_trgm/data/trgm2.data @@ -0,0 +1,696 @@ +Baikal +Baikaluobbal +Lake Baikal +Baikalakko +Baikal Business Centre +Baikal Listvyanka Hotel +Baikal Airfield +Baikalovo +Transbaikalia +Baikal Mountains +Baikal Hotel Moscow +Zabaikalie +Pribaikalskaya +Baikal Plaza +Rubaikale +Tandobai Algad +Daikalay +Bakall +Stubaital +Neustift im Stubaital +Anonyme Appartments Stubaital +Barkaladja Pool +Awabakal Nature Reserve +Awabakal Field Studies Centre +Barkala +Bailallie +Barkala Park +Purba Kalaujan +Nabakalas +Barkal +Baikanthapur +Baikarjhuti +Baika +Baikari +Bakalia Char +Dakshin Bakalia +Purba Kalmegha +Efreytor-Bakalovo +Baykalsko +Baykal +Baskaltsi +Bakalite +Bajkal +Efrejtor Bakalovo +Kampong Bakaladong +Riacho do Sambaibal +Sambaibal +Barkalabava +Zabaykal +Bakalar Lake +Kaikalahun Indian Reserve 25 +Tumba-Kalamba +Kamba-Kalele +Boyagbakala +Bombakalo +Batikalengbe +Bakalukudu +Bakalawa +Bakala +Matamba-Kalenge +Kusu-Bakali +Kambakala +Bakali +Abakalu +Bonagbakala +Bakalua +Bikala Madila +Bikala +Bumba-Kaloki +Tumba-Kalunga +Kabankala +Mambakala +Tumba-Kalumba +Kabakala +Bikalabwa +Bomba-Kalende +Mwalaba-Kalamba +Matamba-Kalenga +Bumba-Kalumba +Bikalange +Kabikala +Mubikale +Kanampumba-Kalawa +Tshiabakale +Bakaly +Bakalongo +Bakale +Bakala Koupi +Bambakala +Bakalou +Tsibakala +Kimbakala +Dabakalakoro +Dabakala +Bakalafoulou +Ngao Bakala +Mobaika +Baimalou +Xibaitaling +Baikai +Baikang +Baitaling +Baikan +Baimaling Linchang +Baimalong +Baikanzui +Baiyali +Baimaling +Baimalang Donggang +Baikangshuoma +Baitaliao +Taikale +Babainale +Bailale +Baibale +Baiwale +Baikangnei +Baitali +Xiabaikan +Bailalong +Baimaluo +Baikacun +Baisala +Bailalin +Baimala +Baidalong +Dabaika +Caikalong +Cuobaikacun +Baikadangcun +Baimalin +Subaika +Gabakkale +Barkallou +Embatkala +Bodega Tabaibal +Golba Kalo +Haikala +Kaikale +Waikaloulevu +Waikalou Creek +Waikalou +Ndelaikalou +Ndelaikalokalo +Bay of Backaland +Bankali +Ker Samba Kalla +Demba Kali +Bakalarr +Baipal +Kalibakalako +Dalabakala +Bikal +Sembaikan +Praikalogu +Tanjung Ompaikalio +Bonebabakal +Tanjung Batikala +Pulau Bakalanpauno +Teluk Bakalan +Bakaltua Bank +Bakalrejo +Bakalan +Sungai Bakaladiyan +Bakal +Buku Baikole +Pulau Baika +Tanjung Bakalinga +Pulau Bakalan +Desa Bakalan +Kebakkalang +Ngambakalang +Mota Sabakal +Bakalan Lor +Babakalo +Buyu Rapanbakalai +Kalimundubakalan +Bakalpokok +Bakaldukuh +Tanabakal +Tanjung Aikaluin +Desa Bakalrejo +Bakalan Kidul +Desa Kebakalan +Kebakalan +Bakalan Kulon +Gunung Bakalan +Kalibakal +Bakaljaya +Trobakal +Bakalan Wetan +Desa Bakal +Alue Bakkala +Uruk Bakal +Bakalbuah +Kwala Bakala +Bakal Lama +Bakal Julu +Bakal Batu +Moncong Baika +Sampangbakalan +Bakalam +Desa Bakalankrapyak +Lebakkalapa Tonggoh +Trembakal +Bakalan Tengah +Kali Bakalan +Desa Cemengbakalan +Desa Bakalanpule +Gunung Bakal +Desa Tambakkalisogo +Tambakkalisogo +Desa Bakalanrayung +Salu Bakalaeng +Bakalaeng +Danau Bakalan +Selat Bakalan +Selat Bakalanpauno +Laikalanda +Bakalinga +Tanjung Mbakalang +Desa Bakalankrajan +Bakalan Dua +Kali Purbakala +Desa Bakalanwringinpitu +Tukad Kubakal +Praikalangga +Banjar Kubakal +Eat Bakal +Sungai Bakala +Kombakalada +Sori Rabakalo +Kahambikalela +Baikarara +Baikapaka +Tukad Bakalan +Teluk Haludubakal +Yabakalewa +Praikalumbang +Waikalowo +Praikalubu +Loko Praikalubu +Ramuk Ombakalada +Praikalebung +Praikaleka +Andabakal +Praikalau +Praikalokat +Praikalimbung +Bambakalo +Leubakkalian +Pematang Baitalimbangan +Lebakalil +Gereba Kaler +Krajan Bakalan +Bakalan Barat +Muarabakal +Umbulan Maharobakal +Bakaldalam +Talang Bakal +Pematang Bakalpanang +Baidaloen +Jatibakal +Tubu Bakalekuk +Dola Peimambakal +Bakalang +Teluk Bakalang +Salu Baidale +Bakalerek +Ile Bakalibu +Parbakalan +Praikalembu +Palindi Laikali +Praikalu +Sori Labakalate +Air Bakal-kecil +Sungaikalung +Sungaikalong +Pematang Bakalpanjang +Payabakal +Waikala +Sungaikali +Sungai Pebakalan +Parit Membakal +Bakalpakebo +Baikat Abu Jaraban +Maikalganj +Maikala Range +Bakalha +Baitalpur +Baikanthpur +Baihal +Barkala Reserved Forest +Babaipalli +Kaikalapettai +Kambainallur +Bakkalale +Kaikalui +Baijalpur +Nehalla Bankalah Reserved Forest +Barkala Rao +Barkali +Baidal +Barkaleh +Darreh Pumba Kal +Bahkalleh +Wibakale +Gaikali +Gagaba Kalo +Barkalare +Bakkalmal +Gora Bakalyadyr +Rodnik Bakalybulak +Urochishche Bakaly +Sopka Bakaly +Gory Bakaly +Bugor Arba-Kalgan +Ozero Baykal +Kolodets Tabakkalgan +Walangivattu Vaikal +Vattevaikal Anicut +Vaikali Tevar Kulam +Vaikalitevan Kulam +Vaikaladichchenai +Uchchodaikallu +Sellapattu Vaikal +Savata Vaikal +Puttadivali Vaikal +Palukadu Vaikal +Mulaikallu Kulam +Koraikallimadu +Koraikalapu Kulam +Karaiyamullivaikal +Karaivaikal Kulam +Kanawali Vaikal +Habakkala +Chalam Vaikal Aru +Ambakala Wewa +Alaikallupoddakulam +Alaikallupodda Alankulam +Akamadi Vaikal +Alaikalluppodda Kulam +Vaikaliththevakulam +Baikole +Sidi Mohammed el Bakali +Sidi Mohammed Bakkal +Sidi Bakal +Oulad el Bakkal +Zaouia Oulad Bakal +Azib el Bakkali +Tombakala +Malaikaly +Ambadikala +Bakalica +Bakalnica +Abankala +Kombakala +Bawkalut +Bakaleko +Bawkalut Chaung +Baukala +Cerro Bainaltzin +Sungai Bakal +Bukit Ubaibalih +Kampong Sombakal +Kampung Lebai Ali +Batikal +Bakalalan Airport +Maikali +Bakalum +Bakalambani +Abakaliki +Tsaunin Maikalaji +Baikaha +Llano Limbaika +Barkald +Barkald stasjon +Barkaleitet +Barkaldfossen +Barkaldvola +Bakkalegskardet +Baikajavri +Barkalden +Bakkalia +Siljabaika +Aikaluokta +Blombakkali +Bavkalasis +Baikajohka +Bakkalykkja +Bakalauri +Bakalauri1 +Bakalauri2 +Bakalauri3 +Bakalauri4 +Bakalauri5 +Bakalauri6 +Bakalauri7 +Bakalauri8 +Bakalauri9 +Bakalsen +Baiyaldi +Naikala +Baikanda +Barkalne +Bakalipur +Bakaldum +Raikal +Baikatte +Maikal +Bakalbhar +Waikalabubu Bay +Baikai Island +Abikal +Boikalakalawa Bay +Maikal River +Bakalao Asibi Point +Bankal +Bakalod Island +Bakalao Point +Bakalan River +Bakal Dos +Bakal Uno +Daang Bakal +Bankal School +Bakal Tres +Kabankalan City Public Plaza +Ranra Tabai Algad +Bairkal Jabal +Bairkal Dhora +Bairkal +Zaibai Algad +Gulba Kalle +Ragha Bakalzai +Dabbarkal Sar +Tabai Algad +Haikalzai +Wuchobai Algad +Jabba Kalai +Goth Soba Kaloi +Baikar Tsarai +Dudgaikal +Baixale Kamar +Zebai Algad +Bakal Khel +Goth Haikal +Haikal +Jaba Kalle +Bakalovina +Salabaikasy +Guba Kalita +Guba Kalgalaksha +Guba Kaldo +Bakalovo +Baykalovo +Baskalino +Sopka Barkaleptskaya +Bakalovskaya Ferma +Bakalinskiy Rayon +Sovkhoz Bakalinskiy +Bakalinskiy +Bakaldy +Bakaldinskoye +Urochishche Bakaldikha +Zabaykalovskiy +Barkalova +Barkalovka +Gora Barkalova +Gora Barkalyu +Bikalamakhi +Stantsiya Bakal +Baykalovskiy Rayon +Baykalovskiy +Baykalovsk +Bakalda +Boloto Malyy Baykal +Boloto Baykal +Zabaykalka +Stantsiya Baykal +Baykalo-Amurskaya Zheleznaya Doroga +Kolkhoz Krasnyy Baykal +Zaliv Baykal +Bakalino +Ovrag Bakalda +Bakaldovshchina +Prud Novyy Baykal +Bakaleyka +Bakalka +Bakaly TV Mast +Urochishche Bakalovo +Kambaika +Maloye Baykalovo +Bakalinskiy Leskhoz +Bikalikha +Kordon Barkalo +Sanatoriy Baykal +Port Baykal +Baykalikha +Polevoy Stan Baykal +Bakalovka +Ramada Makkah Shubaika +Mount Tohebakala +Tambakale Island +Mbanitambaika Island +Mbakalaka Island +Kumbakale +Kaikaloka +Kelesaikal +Nasb Gabakallah +Jabal Barkal +Jabal Abakallah +Al Barkali +Shabakal Abbass +Mabaikuli +Bambakalema +Bambakalia +Baiwala +Babakalia +Baikama +Bankalol +Kundebakali +Yumbaikamadu +Tabakali +Daba Kalharereh +Barkale +Bakalshile +Bakaloolay +Buur Bakaley +Bakaley +Buur Bakale +Bakalaale +Jabal Mobakali +Khor Bakallii +Korombaital +Ambakali +Ba Kaliin +Mbay Bakala +Tagobikala +Fayzabadkala +Aghbai Allazy +Aghbai Alikagar +Gora Fayzabadkala +Daraikalot +Aghbai Alakisirak +Beikala +Foho Berbakalau +Mota Caicabaisala +Sungai Utabailale +Urochishche Bakalarnyn-Ayasy +Urochishche Batkali +Khrebet Batkali +Ras Barkallah +Babakale +Fabrikalar +Bakalukalu Shan +Bakalukalu +Laikala +Waikalakaka +Columbus Bakalar Municipal Airport +Bakalar Library +Bakkala Cemetery +Clifton T Barkalow Elementary School +Barkalow Hollow +Kailuapuhi Waikalua Homesteads +Kawaikalia Gulch +Waikalae +Waikaloa Stream +Waikalua-Loko Fish Pond +Halekou Waikaluakai Homesteads +East Waikalua +Omar Haikal Islamic Academy +Bakalar Air Force Base (historical) +Koshbakaly +Bagkalen +Gora Baikara +Mfumbaika +Mbakalungu +Chumbaika +Ntombankala School +Bakalabwa Pans +Khobai al Janhra +Holiday Inn Dubai Al Barsha +Novotel Dubai Al Barsha +Doubletree Res.Dubai-Al Barsha +Doubletree By Hilton Hotel and Apartments Dubai Al Barsha +Doubletree By Hilton Dubai Al Barsha Hotel and Res +Park Inn By Radisson Dubai Al Barsha +Ramee Rose Hotel Dubai Al Barsha +Aparthotel Adagio Premium Dubai Al Barsha +Ataikala +Selman Marrakech +Riad Ain Marrakech +Taj Palace Marrakech +Delano Marrakech +Pullman Marrakech Palmeraie Resort And Spa +Lalla Calipau Marrakech +Hotel Fashion Marrakech +Four Seasons Resort Marrakech +Adama Resort Marrakech +Pullman Marrakech Palmeraie Re +Ramada Resort Marrakech Douar Al Hana +Hotel Zahia Marrakech +Hotel Marrakech Le Tichka +Le Chems Marrakech +Beachcomber Royal Palm Marrakech +Residence Marrakech +Riad Hermes Marrakech +Riad La Lune De Marrakech +Hotel Marrakech Le Sangho Privilege +Tempoo Hotel Marrakech +Ag Hotel & Spa Marrakech +Palm Appart Club Marrakech +Hotel Ibis Moussafir Marrakech Palmeraie +Ibis Marrakech Gare Voyageurs +Marrakech Ryads Parc And Spa +Terra Mia Marrakech Riad +Residence Dar Lamia Marrakech +Pullman Marrakech Palmeraie Rs +Moussaf Marrakech Centre Gare +Tempoo Hotel Marrakech Adults Only +Sahara Palace Marrakech +Moroccan House Marrakech +El Andalouss And Spa Marrakech +Suite Novotel Marrakech Rs +Dar Catalina Marrakech Hotel Non Refundable Room +Marrakech Hotel +Oued Tammarrakech +Tammarrakech +Cercle de Marrakech-Banlieue +Marrakech-Tensift-Al Haouz +Koudia Marrakech +Hotel Tichka Salam Marrakech +L'Atlas Marrakech +Royal Mirage Deluxe Marrakech +Golden Tulip Farah Marrakech +Ryad Mogador Marrakech +Coralia Club Marrakech Palmariva +La Sultana Marrakech +Marrakech-Medina +Marrakech +Museum of Marrakech +Douar Marrakechiyinc +Ibis Marrakech Centre Gare +Golden Tulip Rawabi Marrakech +Murano Resort Marrakech +Marrakech Garden Hotel +Pullman Marrakech Palmerai Resort & Spa +The Pearl Marrakech +Palais Calipau Marrakech +Hostal Equity Point Marrakech +Sofitel Marrakech Lounge And Spa +Pullman Marrakech Hotel And Spa +Sofitel Marrakech Palais Imperial +Hotel Ibis Moussafir Marrakech Centre Gare +Red Hotel Marrakech +Riad Zenith Marrakech +Ksar Catalina Marrakech Hotel +Blue Sea Hotel Marrakech Ryads Parc & Spa +Bluebay Marrakech +Pullman Marrakech Palmeraie Resort & Spa Hotel +Riad Litzy Marrakech +Sultana Hotel & Spa Marrakech +Albatros Club Marrakech +Hotel Sangho Club Marrakech +Suite Novotel Marrakech Hotel +Riad Utopia Suites & Spa Marrakech +Riad Fatinat Marrakech +Riad Dar El Aila Marrakech +Es Saadi And Casino De Marrakech +Dar Catalina Marrakech Hotel +Grace Marrakech +Marrakesh Apartments +Marrakesh Country Club +Koudiat Lmerrakechiyine +Sidi Mohammed el Marrakchi +Marrakesh +Marrakchien +Marrakchia +Marrakesh Menara Airport +Marrakesh Hua Hin Resort & Spa +Marrakesh Hua Hin Resort And Spa +Marrakesh Resort And Spa (Pool Suite) +Marrakesh Huahin Resort & Spa +Ibis Moussafir Marrakesh Centre Gare Hotel +Maerak-chi +Dar Hammou Ben Merrakchi +Lalla el Marakchia +Khrebet Marrakh +Sungai Maru Kechil +Marrache +Goth Marracha +Maramech Hill +Maramech Woods Nature Preserve +Oued Karakech +Samarra School +Jangal-e Marakeh Sar diff --git a/contrib/pg_trgm/expected/pg_word_trgm.out b/contrib/pg_trgm/expected/pg_word_trgm.out new file mode 100644 index 0000000000..bed61c4922 --- /dev/null +++ b/contrib/pg_trgm/expected/pg_word_trgm.out @@ -0,0 +1,1044 @@ +CREATE TABLE test_trgm2(t text COLLATE "C"); +\copy test_trgm2 from 'data/trgm2.data' +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 +(20 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; + t | sml +------------------------------+----- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 +(4 rows) + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 +(20 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + t | sml +------------------------------+----- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 +(4 rows) + +select t <->> 'Kabankala', t from test_trgm2 order by t <->> 'Kabankala' limit 7; + ?column? | t +----------+---------------------------------- + 0 | Kabankala + 0.1 | Kabankalan City Public Plaza + 0.3 | Abankala + 0.4 | Ntombankala School + 0.416667 | Kabakala + 0.5 | Nehalla Bankalah Reserved Forest + 0.538462 | Kabikala +(7 rows) + +create index trgm_idx2 on test_trgm2 using gist (t gist_trgm_ops); +set enable_seqscan=off; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 +(20 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; + t | sml +------------------------------+----- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 +(4 rows) + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 +(20 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + t | sml +------------------------------+----- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 +(4 rows) + +explain (costs off) +select t <->> 'Kabankala', t from test_trgm2 order by t <->> 'Kabankala' limit 7; + QUERY PLAN +------------------------------------------------ + Limit + -> Index Scan using trgm_idx2 on test_trgm2 + Order By: (t <->> 'Kabankala'::text) +(3 rows) + +select t <->> 'Kabankala', t from test_trgm2 order by t <->> 'Kabankala' limit 7; + ?column? | t +----------+---------------------------------- + 0 | Kabankala + 0.1 | Kabankalan City Public Plaza + 0.3 | Abankala + 0.4 | Ntombankala School + 0.416667 | Kabakala + 0.5 | Nehalla Bankalah Reserved Forest + 0.538462 | Kabikala +(7 rows) + +drop index trgm_idx2; +create index trgm_idx2 on test_trgm2 using gin (t gin_trgm_ops); +set enable_seqscan=off; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 +(20 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; + t | sml +------------------------------+----- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 +(4 rows) + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 +(20 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + t | sml +------------------------------+----- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 +(4 rows) + +set "pg_trgm.word_similarity_threshold" to 0.5; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 + Bakal Batu | 0.571429 + Zabaykalka | 0.571429 + Zabaykalovskiy | 0.571429 +(23 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; + t | sml +----------------------------------+---------- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 + Kabakala | 0.583333 + Nehalla Bankalah Reserved Forest | 0.5 +(6 rows) + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; + t | sml +-------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 + Bakal Batu | 0.571429 + Zabaykalka | 0.571429 + Zabaykalovskiy | 0.571429 +(23 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + t | sml +----------------------------------+---------- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 + Kabakala | 0.583333 + Nehalla Bankalah Reserved Forest | 0.5 +(6 rows) + +set "pg_trgm.word_similarity_threshold" to 0.3; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; + t | sml +-----------------------------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 + Bakal Batu | 0.571429 + Zabaykalka | 0.571429 + Zabaykalovskiy | 0.571429 + Air Bakal-kecil | 0.444444 + Bakal | 0.444444 + Bakal Dos | 0.444444 + Bakal Julu | 0.444444 + Bakal Khel | 0.444444 + Bakal Lama | 0.444444 + Bakal Tres | 0.444444 + Bakal Uno | 0.444444 + Daang Bakal | 0.444444 + Desa Bakal | 0.444444 + Eat Bakal | 0.444444 + Gunung Bakal | 0.444444 + Sidi Bakal | 0.444444 + Stantsiya Bakal | 0.444444 + Sungai Bakal | 0.444444 + Talang Bakal | 0.444444 + Uruk Bakal | 0.444444 + Zaouia Oulad Bakal | 0.444444 + Al Barkali | 0.428571 + Aparthotel Adagio Premium Dubai Al Barsha | 0.428571 + Baikal Business Centre | 0.428571 + Bay of Backaland | 0.428571 + Boikalakalawa Bay | 0.428571 + Doubletree By Hilton Dubai Al Barsha Hotel and Res | 0.428571 + Doubletree By Hilton Hotel and Apartments Dubai Al Barsha | 0.428571 + Doubletree Res.Dubai-Al Barsha | 0.428571 + Holiday Inn Dubai Al Barsha | 0.428571 + Jabal Barkal | 0.428571 + Novotel Dubai Al Barsha | 0.428571 + Park Inn By Radisson Dubai Al Barsha | 0.428571 + Ramee Rose Hotel Dubai Al Barsha | 0.428571 + Waikalabubu Bay | 0.428571 + Baikal | 0.4 + Baikal Airfield | 0.4 + Baikal Hotel Moscow | 0.4 + Baikal Listvyanka Hotel | 0.4 + Baikal Mountains | 0.4 + Baikal Plaza | 0.4 + Bajkal | 0.4 + Bankal | 0.4 + Bankal School | 0.4 + Barkal | 0.4 + Lake Baikal | 0.4 + Mbay Bakala | 0.4 + Oulad el Bakkal | 0.4 + Sidi Mohammed Bakkal | 0.4 + Bairkal | 0.363636 + Bairkal Dhora | 0.363636 + Bairkal Jabal | 0.363636 + Batikal | 0.363636 + Bakala | 0.333333 + Bakala Koupi | 0.333333 + Bakalaale | 0.333333 + Bakalabwa Pans | 0.333333 + Bakalaeng | 0.333333 + Bakalafoulou | 0.333333 + Bakalalan Airport | 0.333333 + Bakalam | 0.333333 + Bakalambani | 0.333333 + Bakalan | 0.333333 + Bakalan Barat | 0.333333 + Bakalan Dua | 0.333333 + Bakalan Kidul | 0.333333 + Bakalan Kulon | 0.333333 + Bakalan Lor | 0.333333 + Bakalan River | 0.333333 + Bakalan Tengah | 0.333333 + Bakalan Wetan | 0.333333 + Bakalang | 0.333333 + Bakalao Asibi Point | 0.333333 + Bakalao Point | 0.333333 + Bakalar Air Force Base (historical) | 0.333333 + Bakalar Lake | 0.333333 + Bakalar Library | 0.333333 + Bakalarr | 0.333333 + Bakalauri | 0.333333 + Bakalauri1 | 0.333333 + Bakalauri2 | 0.333333 + Bakalauri3 | 0.333333 + Bakalauri4 | 0.333333 + Bakalauri5 | 0.333333 + Bakalauri6 | 0.333333 + Bakalauri7 | 0.333333 + Bakalauri8 | 0.333333 + Bakalauri9 | 0.333333 + Bakalawa | 0.333333 + Bakalbhar | 0.333333 + Bakalbuah | 0.333333 + Bakalda | 0.333333 + Bakaldalam | 0.333333 + Bakaldinskoye | 0.333333 + Bakaldovshchina | 0.333333 + Bakaldukuh | 0.333333 + Bakaldum | 0.333333 + Bakaldy | 0.333333 + Bakale | 0.333333 + Bakaleko | 0.333333 + Bakalerek | 0.333333 + Bakaley | 0.333333 + Bakaleyka | 0.333333 + Bakalha | 0.333333 + Bakali | 0.333333 + Bakalia Char | 0.333333 + Bakalica | 0.333333 + Bakalinga | 0.333333 + Bakalino | 0.333333 + Bakalinskiy | 0.333333 + Bakalinskiy Leskhoz | 0.333333 + Bakalinskiy Rayon | 0.333333 + Bakalipur | 0.333333 + Bakalite | 0.333333 + Bakaljaya | 0.333333 + Bakalka | 0.333333 + Bakall | 0.333333 + Bakalnica | 0.333333 + Bakalod Island | 0.333333 + Bakalongo | 0.333333 + Bakaloolay | 0.333333 + Bakalou | 0.333333 + Bakalovina | 0.333333 + Bakalovka | 0.333333 + Bakalovo | 0.333333 + Bakalovskaya Ferma | 0.333333 + Bakalpakebo | 0.333333 + Bakalpokok | 0.333333 + Bakalrejo | 0.333333 + Bakalsen | 0.333333 + Bakalshile | 0.333333 + Bakaltua Bank | 0.333333 + Bakalua | 0.333333 + Bakalukalu | 0.333333 + Bakalukalu Shan | 0.333333 + Bakalukudu | 0.333333 + Bakalum | 0.333333 + Bakaly | 0.333333 + Bakaly TV Mast | 0.333333 + Buur Bakale | 0.333333 + Buur Bakaley | 0.333333 + Columbus Bakalar Municipal Airport | 0.333333 + Dakshin Bakalia | 0.333333 + Danau Bakalan | 0.333333 + Desa Bakalan | 0.333333 + Desa Bakalankrajan | 0.333333 + Desa Bakalankrapyak | 0.333333 + Desa Bakalanpule | 0.333333 + Desa Bakalanrayung | 0.333333 + Desa Bakalanwringinpitu | 0.333333 + Desa Bakalrejo | 0.333333 + Efrejtor Bakalovo | 0.333333 + Efreytor-Bakalovo | 0.333333 + Gora Bakalyadyr | 0.333333 + Gory Bakaly | 0.333333 + Gunung Bakalan | 0.333333 + Ile Bakalibu | 0.333333 + Kali Bakalan | 0.333333 + Kampong Bakaladong | 0.333333 + Khor Bakallii | 0.333333 + Krajan Bakalan | 0.333333 + Kusu-Bakali | 0.333333 + Kwala Bakala | 0.333333 + Ngao Bakala | 0.333333 + Ovrag Bakalda | 0.333333 + Pematang Bakalpanang | 0.333333 + Pematang Bakalpanjang | 0.333333 + Pulau Bakalan | 0.333333 + Pulau Bakalanpauno | 0.333333 + Ragha Bakalzai | 0.333333 + Rodnik Bakalybulak | 0.333333 + Salu Bakalaeng | 0.333333 + Selat Bakalan | 0.333333 + Selat Bakalanpauno | 0.333333 + Sidi Mohammed el Bakali | 0.333333 + Sopka Bakaly | 0.333333 + Sovkhoz Bakalinskiy | 0.333333 + Sungai Bakala | 0.333333 + Sungai Bakaladiyan | 0.333333 + Tanjung Bakalinga | 0.333333 + Teluk Bakalan | 0.333333 + Teluk Bakalang | 0.333333 + Tubu Bakalekuk | 0.333333 + Tukad Bakalan | 0.333333 + Urochishche Bakalarnyn-Ayasy | 0.333333 + Urochishche Bakaldikha | 0.333333 + Urochishche Bakalovo | 0.333333 + Urochishche Bakaly | 0.333333 + Bakkalmal | 0.307692 + Alue Bakkala | 0.3 + Azib el Bakkali | 0.3 + Ba Kaliin | 0.3 + Bagkalen | 0.3 + Bahkalleh | 0.3 + Baikalakko | 0.3 + Baikalovo | 0.3 + Baikaluobbal | 0.3 + Bakkala Cemetery | 0.3 + Bakkalale | 0.3 + Bakkalegskardet | 0.3 + Bakkalia | 0.3 + Bakkalykkja | 0.3 + Bankali | 0.3 + Bankalol | 0.3 + Barkala | 0.3 + Barkala Park | 0.3 + Barkala Rao | 0.3 + Barkala Reserved Forest | 0.3 + Barkalabava | 0.3 + Barkaladja Pool | 0.3 + Barkalare | 0.3 + Barkald | 0.3 + Barkald stasjon | 0.3 + Barkalden | 0.3 + Barkaldfossen | 0.3 + Barkaldvola | 0.3 + Barkale | 0.3 + Barkaleh | 0.3 + Barkaleitet | 0.3 + Barkali | 0.3 + Barkallou | 0.3 + Barkalne | 0.3 + Barkalova | 0.3 + Barkalovka | 0.3 + Barkalow Hollow | 0.3 + Baskalino | 0.3 + Baskaltsi | 0.3 + Baukala | 0.3 + Bavkalasis | 0.3 + Bawkalut | 0.3 + Bawkalut Chaung | 0.3 + Bikal | 0.3 + Clifton T Barkalow Elementary School | 0.3 + Gora Barkalova | 0.3 + Gora Barkalyu | 0.3 + Khrebet Batkali | 0.3 + Kordon Barkalo | 0.3 + Nehalla Bankalah Reserved Forest | 0.3 + Ras Barkallah | 0.3 + Sopka Barkaleptskaya | 0.3 + Urochishche Batkali | 0.3 +(261 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; + t | sml +----------------------------------+---------- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 + Kabakala | 0.583333 + Nehalla Bankalah Reserved Forest | 0.5 + Kabikala | 0.461538 + Mwalaba-Kalamba | 0.454545 + Bakala Koupi | 0.4 + Bankal | 0.4 + Bankal School | 0.4 + Bankali | 0.4 + Bankalol | 0.4 + Jabba Kalai | 0.4 + Kanampumba-Kalawa | 0.4 + Purba Kalaujan | 0.4 + Tumba-Kalamba | 0.4 + Daba Kalharereh | 0.363636 + Gagaba Kalo | 0.363636 + Jaba Kalle | 0.363636 + Dabakala | 0.333333 + Dalabakala | 0.333333 + Kambakala | 0.333333 + Ker Samba Kalla | 0.333333 + Fayzabadkala | 0.307692 + Gora Fayzabadkala | 0.307692 + Guba Kalgalaksha | 0.307692 + Habakkala | 0.307692 + Kaikalahun Indian Reserve 25 | 0.307692 + Kaikalapettai | 0.307692 + Alue Bakkala | 0.3 + Ambadikala | 0.3 + Ambakala Wewa | 0.3 + Ataikala | 0.3 + Ba Kaliin | 0.3 + Bakala | 0.3 + Bakkala Cemetery | 0.3 + Bambakala | 0.3 + Barkala | 0.3 + Barkala Park | 0.3 + Barkala Rao | 0.3 + Barkala Reserved Forest | 0.3 + Baukala | 0.3 + Beikala | 0.3 + Bikala | 0.3 + Bikala Madila | 0.3 + Bomba-Kalende | 0.3 + Bonagbakala | 0.3 + Boyagbakala | 0.3 + Bugor Arba-Kalgan | 0.3 + Bumba-Kaloki | 0.3 + Bumba-Kalumba | 0.3 + Darreh Pumba Kal | 0.3 + Demba Kali | 0.3 + Embatkala | 0.3 + Gereba Kaler | 0.3 + Golba Kalo | 0.3 + Goth Soba Kaloi | 0.3 + Guba Kaldo | 0.3 + Guba Kalita | 0.3 + Gulba Kalle | 0.3 + Haikala | 0.3 + Kali Bakalan | 0.3 + Kali Purbakala | 0.3 + Kalibakal | 0.3 + Kalibakalako | 0.3 + Kalimundubakalan | 0.3 + Kamba-Kalele | 0.3 + Kimbakala | 0.3 + Kombakala | 0.3 + Kwala Bakala | 0.3 + Laikala | 0.3 + Maikala Range | 0.3 + Mambakala | 0.3 + Matamba-Kalenga | 0.3 + Matamba-Kalenge | 0.3 + Mbay Bakala | 0.3 + Mount Tohebakala | 0.3 + Naikala | 0.3 + Ngao Bakala | 0.3 + Purba Kalmegha | 0.3 + Sungai Bakala | 0.3 + Tagobikala | 0.3 + Tanjung Batikala | 0.3 + Tombakala | 0.3 + Tsibakala | 0.3 + Tumba-Kalumba | 0.3 + Tumba-Kalunga | 0.3 + Waikala | 0.3 +(89 rows) + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; + t | sml +-----------------------------------------------------------+---------- + Baykal | 1 + Boloto Baykal | 1 + Boloto Malyy Baykal | 1 + Kolkhoz Krasnyy Baykal | 1 + Ozero Baykal | 1 + Polevoy Stan Baykal | 1 + Port Baykal | 1 + Prud Novyy Baykal | 1 + Sanatoriy Baykal | 1 + Stantsiya Baykal | 1 + Zaliv Baykal | 1 + Baykalikha | 0.857143 + Baykalo-Amurskaya Zheleznaya Doroga | 0.857143 + Baykalovo | 0.857143 + Baykalovsk | 0.857143 + Baykalovskiy | 0.857143 + Baykalovskiy Rayon | 0.857143 + Baykalsko | 0.857143 + Maloye Baykalovo | 0.857143 + Zabaykal | 0.714286 + Bakal Batu | 0.571429 + Zabaykalka | 0.571429 + Zabaykalovskiy | 0.571429 + Air Bakal-kecil | 0.444444 + Bakal | 0.444444 + Bakal Dos | 0.444444 + Bakal Julu | 0.444444 + Bakal Khel | 0.444444 + Bakal Lama | 0.444444 + Bakal Tres | 0.444444 + Bakal Uno | 0.444444 + Daang Bakal | 0.444444 + Desa Bakal | 0.444444 + Eat Bakal | 0.444444 + Gunung Bakal | 0.444444 + Sidi Bakal | 0.444444 + Stantsiya Bakal | 0.444444 + Sungai Bakal | 0.444444 + Talang Bakal | 0.444444 + Uruk Bakal | 0.444444 + Zaouia Oulad Bakal | 0.444444 + Al Barkali | 0.428571 + Aparthotel Adagio Premium Dubai Al Barsha | 0.428571 + Baikal Business Centre | 0.428571 + Bay of Backaland | 0.428571 + Boikalakalawa Bay | 0.428571 + Doubletree By Hilton Dubai Al Barsha Hotel and Res | 0.428571 + Doubletree By Hilton Hotel and Apartments Dubai Al Barsha | 0.428571 + Doubletree Res.Dubai-Al Barsha | 0.428571 + Holiday Inn Dubai Al Barsha | 0.428571 + Jabal Barkal | 0.428571 + Novotel Dubai Al Barsha | 0.428571 + Park Inn By Radisson Dubai Al Barsha | 0.428571 + Ramee Rose Hotel Dubai Al Barsha | 0.428571 + Waikalabubu Bay | 0.428571 + Baikal | 0.4 + Baikal Airfield | 0.4 + Baikal Hotel Moscow | 0.4 + Baikal Listvyanka Hotel | 0.4 + Baikal Mountains | 0.4 + Baikal Plaza | 0.4 + Bajkal | 0.4 + Bankal | 0.4 + Bankal School | 0.4 + Barkal | 0.4 + Lake Baikal | 0.4 + Mbay Bakala | 0.4 + Oulad el Bakkal | 0.4 + Sidi Mohammed Bakkal | 0.4 + Bairkal | 0.363636 + Bairkal Dhora | 0.363636 + Bairkal Jabal | 0.363636 + Batikal | 0.363636 + Bakala | 0.333333 + Bakala Koupi | 0.333333 + Bakalaale | 0.333333 + Bakalabwa Pans | 0.333333 + Bakalaeng | 0.333333 + Bakalafoulou | 0.333333 + Bakalalan Airport | 0.333333 + Bakalam | 0.333333 + Bakalambani | 0.333333 + Bakalan | 0.333333 + Bakalan Barat | 0.333333 + Bakalan Dua | 0.333333 + Bakalan Kidul | 0.333333 + Bakalan Kulon | 0.333333 + Bakalan Lor | 0.333333 + Bakalan River | 0.333333 + Bakalan Tengah | 0.333333 + Bakalan Wetan | 0.333333 + Bakalang | 0.333333 + Bakalao Asibi Point | 0.333333 + Bakalao Point | 0.333333 + Bakalar Air Force Base (historical) | 0.333333 + Bakalar Lake | 0.333333 + Bakalar Library | 0.333333 + Bakalarr | 0.333333 + Bakalauri | 0.333333 + Bakalauri1 | 0.333333 + Bakalauri2 | 0.333333 + Bakalauri3 | 0.333333 + Bakalauri4 | 0.333333 + Bakalauri5 | 0.333333 + Bakalauri6 | 0.333333 + Bakalauri7 | 0.333333 + Bakalauri8 | 0.333333 + Bakalauri9 | 0.333333 + Bakalawa | 0.333333 + Bakalbhar | 0.333333 + Bakalbuah | 0.333333 + Bakalda | 0.333333 + Bakaldalam | 0.333333 + Bakaldinskoye | 0.333333 + Bakaldovshchina | 0.333333 + Bakaldukuh | 0.333333 + Bakaldum | 0.333333 + Bakaldy | 0.333333 + Bakale | 0.333333 + Bakaleko | 0.333333 + Bakalerek | 0.333333 + Bakaley | 0.333333 + Bakaleyka | 0.333333 + Bakalha | 0.333333 + Bakali | 0.333333 + Bakalia Char | 0.333333 + Bakalica | 0.333333 + Bakalinga | 0.333333 + Bakalino | 0.333333 + Bakalinskiy | 0.333333 + Bakalinskiy Leskhoz | 0.333333 + Bakalinskiy Rayon | 0.333333 + Bakalipur | 0.333333 + Bakalite | 0.333333 + Bakaljaya | 0.333333 + Bakalka | 0.333333 + Bakall | 0.333333 + Bakalnica | 0.333333 + Bakalod Island | 0.333333 + Bakalongo | 0.333333 + Bakaloolay | 0.333333 + Bakalou | 0.333333 + Bakalovina | 0.333333 + Bakalovka | 0.333333 + Bakalovo | 0.333333 + Bakalovskaya Ferma | 0.333333 + Bakalpakebo | 0.333333 + Bakalpokok | 0.333333 + Bakalrejo | 0.333333 + Bakalsen | 0.333333 + Bakalshile | 0.333333 + Bakaltua Bank | 0.333333 + Bakalua | 0.333333 + Bakalukalu | 0.333333 + Bakalukalu Shan | 0.333333 + Bakalukudu | 0.333333 + Bakalum | 0.333333 + Bakaly | 0.333333 + Bakaly TV Mast | 0.333333 + Buur Bakale | 0.333333 + Buur Bakaley | 0.333333 + Columbus Bakalar Municipal Airport | 0.333333 + Dakshin Bakalia | 0.333333 + Danau Bakalan | 0.333333 + Desa Bakalan | 0.333333 + Desa Bakalankrajan | 0.333333 + Desa Bakalankrapyak | 0.333333 + Desa Bakalanpule | 0.333333 + Desa Bakalanrayung | 0.333333 + Desa Bakalanwringinpitu | 0.333333 + Desa Bakalrejo | 0.333333 + Efrejtor Bakalovo | 0.333333 + Efreytor-Bakalovo | 0.333333 + Gora Bakalyadyr | 0.333333 + Gory Bakaly | 0.333333 + Gunung Bakalan | 0.333333 + Ile Bakalibu | 0.333333 + Kali Bakalan | 0.333333 + Kampong Bakaladong | 0.333333 + Khor Bakallii | 0.333333 + Krajan Bakalan | 0.333333 + Kusu-Bakali | 0.333333 + Kwala Bakala | 0.333333 + Ngao Bakala | 0.333333 + Ovrag Bakalda | 0.333333 + Pematang Bakalpanang | 0.333333 + Pematang Bakalpanjang | 0.333333 + Pulau Bakalan | 0.333333 + Pulau Bakalanpauno | 0.333333 + Ragha Bakalzai | 0.333333 + Rodnik Bakalybulak | 0.333333 + Salu Bakalaeng | 0.333333 + Selat Bakalan | 0.333333 + Selat Bakalanpauno | 0.333333 + Sidi Mohammed el Bakali | 0.333333 + Sopka Bakaly | 0.333333 + Sovkhoz Bakalinskiy | 0.333333 + Sungai Bakala | 0.333333 + Sungai Bakaladiyan | 0.333333 + Tanjung Bakalinga | 0.333333 + Teluk Bakalan | 0.333333 + Teluk Bakalang | 0.333333 + Tubu Bakalekuk | 0.333333 + Tukad Bakalan | 0.333333 + Urochishche Bakalarnyn-Ayasy | 0.333333 + Urochishche Bakaldikha | 0.333333 + Urochishche Bakalovo | 0.333333 + Urochishche Bakaly | 0.333333 + Bakkalmal | 0.307692 + Alue Bakkala | 0.3 + Azib el Bakkali | 0.3 + Ba Kaliin | 0.3 + Bagkalen | 0.3 + Bahkalleh | 0.3 + Baikalakko | 0.3 + Baikalovo | 0.3 + Baikaluobbal | 0.3 + Bakkala Cemetery | 0.3 + Bakkalale | 0.3 + Bakkalegskardet | 0.3 + Bakkalia | 0.3 + Bakkalykkja | 0.3 + Bankali | 0.3 + Bankalol | 0.3 + Barkala | 0.3 + Barkala Park | 0.3 + Barkala Rao | 0.3 + Barkala Reserved Forest | 0.3 + Barkalabava | 0.3 + Barkaladja Pool | 0.3 + Barkalare | 0.3 + Barkald | 0.3 + Barkald stasjon | 0.3 + Barkalden | 0.3 + Barkaldfossen | 0.3 + Barkaldvola | 0.3 + Barkale | 0.3 + Barkaleh | 0.3 + Barkaleitet | 0.3 + Barkali | 0.3 + Barkallou | 0.3 + Barkalne | 0.3 + Barkalova | 0.3 + Barkalovka | 0.3 + Barkalow Hollow | 0.3 + Baskalino | 0.3 + Baskaltsi | 0.3 + Baukala | 0.3 + Bavkalasis | 0.3 + Bawkalut | 0.3 + Bawkalut Chaung | 0.3 + Bikal | 0.3 + Clifton T Barkalow Elementary School | 0.3 + Gora Barkalova | 0.3 + Gora Barkalyu | 0.3 + Khrebet Batkali | 0.3 + Kordon Barkalo | 0.3 + Nehalla Bankalah Reserved Forest | 0.3 + Ras Barkallah | 0.3 + Sopka Barkaleptskaya | 0.3 + Urochishche Batkali | 0.3 +(261 rows) + +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + t | sml +----------------------------------+---------- + Kabankala | 1 + Kabankalan City Public Plaza | 0.9 + Abankala | 0.7 + Ntombankala School | 0.6 + Kabakala | 0.583333 + Nehalla Bankalah Reserved Forest | 0.5 + Kabikala | 0.461538 + Mwalaba-Kalamba | 0.454545 + Bakala Koupi | 0.4 + Bankal | 0.4 + Bankal School | 0.4 + Bankali | 0.4 + Bankalol | 0.4 + Jabba Kalai | 0.4 + Kanampumba-Kalawa | 0.4 + Purba Kalaujan | 0.4 + Tumba-Kalamba | 0.4 + Daba Kalharereh | 0.363636 + Gagaba Kalo | 0.363636 + Jaba Kalle | 0.363636 + Dabakala | 0.333333 + Dalabakala | 0.333333 + Kambakala | 0.333333 + Ker Samba Kalla | 0.333333 + Fayzabadkala | 0.307692 + Gora Fayzabadkala | 0.307692 + Guba Kalgalaksha | 0.307692 + Habakkala | 0.307692 + Kaikalahun Indian Reserve 25 | 0.307692 + Kaikalapettai | 0.307692 + Alue Bakkala | 0.3 + Ambadikala | 0.3 + Ambakala Wewa | 0.3 + Ataikala | 0.3 + Ba Kaliin | 0.3 + Bakala | 0.3 + Bakkala Cemetery | 0.3 + Bambakala | 0.3 + Barkala | 0.3 + Barkala Park | 0.3 + Barkala Rao | 0.3 + Barkala Reserved Forest | 0.3 + Baukala | 0.3 + Beikala | 0.3 + Bikala | 0.3 + Bikala Madila | 0.3 + Bomba-Kalende | 0.3 + Bonagbakala | 0.3 + Boyagbakala | 0.3 + Bugor Arba-Kalgan | 0.3 + Bumba-Kaloki | 0.3 + Bumba-Kalumba | 0.3 + Darreh Pumba Kal | 0.3 + Demba Kali | 0.3 + Embatkala | 0.3 + Gereba Kaler | 0.3 + Golba Kalo | 0.3 + Goth Soba Kaloi | 0.3 + Guba Kaldo | 0.3 + Guba Kalita | 0.3 + Gulba Kalle | 0.3 + Haikala | 0.3 + Kali Bakalan | 0.3 + Kali Purbakala | 0.3 + Kalibakal | 0.3 + Kalibakalako | 0.3 + Kalimundubakalan | 0.3 + Kamba-Kalele | 0.3 + Kimbakala | 0.3 + Kombakala | 0.3 + Kwala Bakala | 0.3 + Laikala | 0.3 + Maikala Range | 0.3 + Mambakala | 0.3 + Matamba-Kalenga | 0.3 + Matamba-Kalenge | 0.3 + Mbay Bakala | 0.3 + Mount Tohebakala | 0.3 + Naikala | 0.3 + Ngao Bakala | 0.3 + Purba Kalmegha | 0.3 + Sungai Bakala | 0.3 + Tagobikala | 0.3 + Tanjung Batikala | 0.3 + Tombakala | 0.3 + Tsibakala | 0.3 + Tumba-Kalumba | 0.3 + Tumba-Kalunga | 0.3 + Waikala | 0.3 +(89 rows) + diff --git a/contrib/pg_trgm/sql/pg_word_trgm.sql b/contrib/pg_trgm/sql/pg_word_trgm.sql new file mode 100644 index 0000000000..4b1db9706a --- /dev/null +++ b/contrib/pg_trgm/sql/pg_word_trgm.sql @@ -0,0 +1,42 @@ +CREATE TABLE test_trgm2(t text COLLATE "C"); + +\copy test_trgm2 from 'data/trgm2.data' + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; +select t <->> 'Kabankala', t from test_trgm2 order by t <->> 'Kabankala' limit 7; + +create index trgm_idx2 on test_trgm2 using gist (t gist_trgm_ops); +set enable_seqscan=off; + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + +explain (costs off) +select t <->> 'Kabankala', t from test_trgm2 order by t <->> 'Kabankala' limit 7; +select t <->> 'Kabankala', t from test_trgm2 order by t <->> 'Kabankala' limit 7; + +drop index trgm_idx2; +create index trgm_idx2 on test_trgm2 using gin (t gin_trgm_ops); +set enable_seqscan=off; + +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + +set "pg_trgm.word_similarity_threshold" to 0.5; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t; + +set "pg_trgm.word_similarity_threshold" to 0.3; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where 'Baykal' <% t order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where 'Kabankala' <% t order by sml desc, t; +select t,word_similarity('Baykal',t) as sml from test_trgm2 where t %> 'Baykal' order by sml desc, t; +select t,word_similarity('Kabankala',t) as sml from test_trgm2 where t %> 'Kabankala' order by sml desc, t;