![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, My problem is that in one of my tables I have a column for 'name'. It can have from two to ten or mores words in it, separated by spaces. It's a varchar(200) field. What I want to have is a quick search on this column available to the clients. But, I want all words in 'name' to be searchable and fast. I could not find any answer to this. If 'name' had a fixes number of words in it, I could separate the varios words into different columns like 'name1', 'name2', etc. But this is not the case. The search should be case insensitive. I've created a standard btree index but I don't know if it is of any use. Is there any solution for this? I guess there is! |
#3
| |||
| |||
|
|
Hi, are you sure, that this column is in the right place? To me it sounds like you should have a second table containing the (indexed) "name" column and a foreign key referencing your first tables PK. Christoph I don't see any advantage in what you're proposing. |
#4
| |||
| |||
|
|
are you sure, that this column is in the right place? To me it sounds like you should have a second table containing the (indexed) "name" column and a foreign key referencing your first tables PK. Christoph I don't see any advantage in what you're proposing. Each record in the table has for the 'name' field something like: 'Luis Mendes Cristoph Mark David Smith' 'Michael Bush' 'Mark Steve Browne' I just want a user to be able to search for 'Mark' and get results from the first and third lines. It should not matter where 'Mark' is placed. It might become a matter of [lacking] performance |
#5
| |||
| |||
|
|
Hi, My problem is that in one of my tables I have a column for 'name'. It can have from two to ten or mores words in it, separated by spaces. It's a varchar(200) field. What I want to have is a quick search on this column available to the clients. I've read the documentation. I found that btree indexes would be very efficient if I was to search for the first word of 'name'. But, I want all words in 'name' to be searchable and fast. I could not find any answer to this. If 'name' had a fixes number of words in it, I could separate the varios words into different columns like 'name1', 'name2', etc. But this is not the case. The search should be case insensitive. I've created a standard btree index but I don't know if it is of any use. Is there any solution for this? I guess there is! Maybe, I need a function to grab all words from all records and build an index with it. But how? I'd apreciate any help on this. |
#6
| |||
| |||
|
|
Hi, are you sure, that this column is in the right place? To me it sounds like you should have a second table containing the (indexed) "name" column and a foreign key referencing your first tables PK. Christoph I don't see any advantage in what you're proposing. The name column in a second table would contain one name for each row, so it |
|
Each record in the table has for the 'name' field something like: 'Luis Mendes Cristoph Mark David Smith' 'Michael Bush' 'Mark Steve Browne' I just want a user to be able to search for 'Mark' and get results from the first and third lines. It should not matter where 'Mark' is placed. Luis |
#7
| |||
| |||
|
|
Hi Luis, Try looking into tsearch2 in the contrib folder. It is a module that facilitates full-text indexing which is what you are trying to do. When 8.2 is released, it will be in the core postgresql IIRC. http://www.sai.msu.su/~megera/postgr...-V2-intro.html |
![]() |
| Thread Tools | |
| Display Modes | |
| |