I need to create suggestion autocomplete for all the columns of a table in a single searchbox using postgres database.
I have a search autocomplete in web page and need to autosuggest the options. All columns are varchar.
For searching I am using the approach like
select * from userschema.user_details where to_tsvector(user_details::text) ## to_tsquery('text:*')
But I am facing an issue getting the options for autocomplete.
Is there a way of searching the tsvector and getting all the options that match a criteria.
Something like getting text* options from all the words of tsvector so that I can use them for autosuggest.
I am thinking of storing the contents of tsvector into a column.
Is there a way of fetching autosuggest words from same?
Related
I've implemented the full text search by using tsvector and tsquery. It is not working when there is a comma present in the database.
I'm using the below query to search the result and it is not fetching any row.
select ndc,ln60
from rndc14_ndc_mstr
where (to_tsvector(ln60) ## plainto_tsquery('Metformin 1000'));
Below are the data present in the database with matching of above string.
We hit a bug with our PostreSQL full text search system where a user whose first name is "Don" was not being included in search results. After some digging, we found that "don" is listed as a stopword in the default full text search dictionary in PostgreSQL (https://github.com/postgres/postgres/blob/master/src/backend/snowball/stopwords/english.stop).
We are using a hosted DB solution so we don't have access to the file system and thus can't create a modified version of the stopword file.
Are there any workarounds for this other than doing a string comparison check? Given that there can be multiple search tokens, it seems pretty bad to have to perform a string comparison of the name fields against every search token.
All the other words in the English stopword file seem pretty reasonable, but I'm really surprised I don't see any other Google/SO results complaining about users named "Don".
Maybe this makes it clear why don is a stopword:
SELECT to_tsvector('english', 'don''t');
to_tsvector
-------------
(1 row)
You wouldn't want to remove that stop word.
Full text search is not useful for proper names.
Normally, trigram indexes are better for that.
I would like to create a Query in VS Team Services > Work > Queries that searches all fields in Work Items that are indexed for full-text search.
To search for the text "confusing", I can create a query for
Title contains confusing
OR Description contains confusing
OR Steps to Repro contains confusing
OR History contains confusing
Is there a better way?
You can easily do so using Work Item Search. Just go to Work hub and type in the text "confusing" in the search box and hit Enter.
As far as I can tell, the search filter in the navigator will only search available database names, not table names.
If you click on a table name and start typing, it appears that a simple search can be performed beginning with the first letter of the tables.
I'm looking for way to be able to search all table names in a selected database. Sometimes there can be a lot of tables to sort through. It seems like a feature that would likely be there and I can't find it.
Found out the answer...
If you type for example *.test_table or the schema name instead of the asterisk it will filter them. The key is that the schema/database must be specified in the search query. The asterisk notation works with the table names as well. For example *.*test* will filter any table in any schema with test anywhere in the table name.
You can use the command
SHOW TABLES like '%%';
To have it always in your tools, you can add it as a snippet to SQL aditions panel on the right.
Then you can always either bring it in your editor and type your search key between %%, or just execute it as it is (It will fetch all the tables of the database) and then just filter using the "filter rows" input of the result set.
I have a Table that I want to search its title(nvarchar(max)) column.
But I am getting an error when I create an index over the title column so I can enable Full Text search on it.
I am going to use the Contains keyword to do the job.
Any ideas?
Thanks,
You say in the comments
When I create the index over the
column Title, I get an error stating
that you cannot create an index over a
column of this type
This sounds like you are trying to create a regular index on it not a full text index. Right click the table in SSMS and choose "Full Text Index" to set up full text indexing.
If this option is greyed out you might need to run exec sp_fulltext_database 'enable' first.