SQL Server Full-Text search Empty catalog - sql-server

I'm trying to get a full-text search running on SQL Server in Azure.
My data is in a varbinary(max) with all columns containing data. The data is strings of html.
The SearchableData column is computed and filled using:
CONVERT(VARBINARY(MAX),[Title] + [Body])
Doing a select and a convert back yields data.
I would like to utilize the built in html filter of SQL Server.
If I do the following I can search and everything works, however, without a filter:
CREATE FULLTEXT INDEX
ON ArticleContent (Body LANGUAGE 0, Title LANGUAGE 0)
KEY INDEX PK_ArticleContent ON AcademyFTS
WITH (STOPLIST = SYSTEM, CHANGE_TRACKING AUTO)
However, I want to be able to utalize the .html filtering.
I've created the following:
CREATE FULLTEXT CATALOG AcademyFTS WITH ACCENT_SENSITIVITY = OFF AS DEFAULT
and
CREATE FULLTEXT INDEX
ON ArticleContent (SearchableData TYPE COLUMN FileExtension LANGUAGE 0)
KEY INDEX PK_ArticleContent ON AcademyFTS
WITH (STOPLIST = SYSTEM, CHANGE_TRACKING AUTO)
However the catalog is empty and I don't get any results back from a simple search
SELECT *
FROM ArticleContent
WHERE FREETEXT(SearchableData, 'wiki')
I've been using these two guides:
Hands on Full-Text Search in SQL Server
How to implement a full-text search on HTML documents with Microsoft SQL Server

I found the answer!
You can't full-text search on a computed column! :)
Microsoft Docs

Related

Full Text not indexing varbinary column (with html)

I have a table with HTML data, that I want to search using the Full Text Index via an html-filter
So I created an index:
CREATE FULLTEXT CATALOG myCatalog AS DEFAULT
CREATE FULLTEXT INDEX ON myTable (Body TYPE COLUMN Filetype)
KEY INDEX PK_myTable
Body is a varbinary(max) column with HTML. The Filetype column is a computed column returns .html.
No results are being returned.
I verified that .html filter is installed. FullText index is also installed properly and works fine if I convert the column to nvarchar and create just a "plain text" index (not html).
No errors in the SQL log or FTS log.
The keywords table is just empty!
SELECT *
FROM sys.dm_fts_index_keywords
(DB_ID('myDatabase'), OBJECT_ID('myTable'))
All it returns is "END OF FILE" symbol.
It says "document count 35" which mean the documents were processed, but no keywords were extracted.
PS. I have SQL Server Express Edition 2012 (with all advanced features including full text). Can this be the reason? But again, the "plain" full text search works just fine!
PPS. Asked my coworker to test this on SQL Express 2016 - same result... Tried on our production server "Enterprise" edition - same.
UPDATE
OK it turns out the full text index DOES NOT SUPPORT UNICODE!! in varbinary columns. When I converted the column to non-unicode (by converting it to nvarchar then to varchar and then back to varbinary) It started working.
Anyone knows any workarounds?
OK, so it turns out fulltext index DOES support unicode data in varbinary but pay attention to this:
If your varbinary column is created from Nvarchar be sure to include the 0xFFFE unicode signature at the beginning
For example, I'm using a computed column for full text index, so I had to change my computed column to this:
alter table myTable
add FTS_Body as 0xFFFE + (CAST(HtmlBody as VARBINARY(MAX)))
--HtmlBody is my nvarchar column that contains html

ArcGIS SQL Server ArcSDE: Versioning vs Identity Column

[I am asking here instead of GIS Stackexchange because this maybe more of a SQL Server issue?]
I have SQL Server ArcSDE connection in which data is batch inserted via some scripts. Currently, anytime there is a new row of data then an 'OBJECTID' column, set to INT and Identity Column increases by number 1. So far so good. Except I need to enable "versioning" on the table.
And so I follow this: http://resources.arcgis.com/en/help/main/10.1/index.html#//003n000000v3000000
but get errors because ArcGIS is complaining about the Identity column, per: http://support.esri.com/cn/knowledgebase/techarticles/detail/40329 ; and when I remove the Identity attribute to the column then the column value becomes NULL--not good.
So, in my scenario, how I can I increase the value of OBJECTID by 1 number as auto-increment? I supposed, I can just insert some GUID into the 'OBJECTID' field through the script? Also, if I follow the GUID route then I am not sure if I will be able to add rows manually via ArcGIS Desktop on occasional basis?
Thanks!
Update 1 Okay, so changed the OBJECTID field to a 'uniqueidentifier' one with a default GUID value and now I am able to enable "versioning" using ArcGIS Desktop. However, ArcGIS is expecting GUID to be an INT data type--and so no go?
In light of my "update 1" in the Question above I managed to take care of this by inserting an INT value for OBJECTID during the batch insertions per the following: How to insert an auto_increment key into SQL Server table
so per the above link, I ended doing:
INSERT INTO bo.TABLE (primary_key, field1, fiels2) VALUES ((SELECT ISNULL(MAX(id) + 1, 0) FROM bo.Table), value1, value2)
EXCEPT in my case the IDENTITY remains not 'ON' at all either in the database or, unlike the above link, I didn't have to set Identity On/Off during batch insertions; Works for some reasons anyway!

SQL Server - Script to update Full text Catalogue Index

I have a full text search index in the development environment. It contains data of the table to be indexed and the coulmns selected for the full text indexing. I viewed it through Management Studio.
I need to update the selected columns of the index in the acceptance environment. Can I generate a script for this purpose.
I tried generating a script of the index by goining into "Storage" > Under "Full text Catalogs" > Right click on the Index > select "Script Catalog as" > select "Drop and Create to". But it gives a very basic script, The columns of the table which I need to associate in the index are not generated in the script. The script i get is as below:
DROP FULLTEXT CATALOG [MYTABLE]
GO
CREATE FULLTEXT CATALOG [MYTABLE]WITH ACCENT_SENSITIVITY = OFF
GO
But what I need is to change the selected columns of the table in the index.
You can generate the script for the full text index by scripting the table, but first you need to enable the Script full-text indexes option as follows:
In SQL Server Management Studio, click the Tools menu > Options
In the left pane select SQL Server Object Explorer > Scripting
In the right pane under Table and view options, set Script full-text indexes to True.
Once that option is set, right-click the table and select Script Table as > CREATE To (or DROP and CREATE To). The relevant part of the script looks something like this:
CREATE FULLTEXT INDEX ON [dbo].[Table1] (
[Column1] LANGUAGE 'Neutral'
)
KEY INDEX [PK_MyTable] ON ([MYTABLE], FILEGROUP [PRIMARY])
WITH (CHANGE_TRACKING = AUTO, STOPLIST = SYSTEM)
GO
(where MYTABLE is the name of the full text catalog, based on the original question)

How can i import indexes into ms SQL Server?

I created a new databases , and added tables using the import data wizard. But the wizard din't create the indexed and constraint's on the table. How can I Import indexes?
If your source is also SQL Server, you should be able to run Tasks -> Generate Scripts and select "Script Indexes" in the list of options for the old database and execute the script on the new database with maybe a change in database name.
Just manually add indexes to your table
Here is an example from MSDN:
This example creates an index on the au_id column of the authors table.
SET NOCOUNT OFF
USE pubs
IF EXISTS (SELECT name FROM sysindexes
WHERE name = 'au_id_ind')
DROP INDEX authors.au_id_ind
GO
USE pubs
CREATE INDEX au_id_ind
ON authors (au_id)
GO
The other way you can do this is open the table in design mode management studio, highlight the field you want to index and look at the options at the top. One of them is for indexes and you can simply manually add it and give it a name right in management studio.

Using Full-Text-Search in order to find partial words (SQL Server 2008)

I'm trying to build a facebook like search for my software.
I'd like to query the table customers.
I've set up a FULLTEXT Index and tried the next query
SELECT * FROM Customer where CONTAINS(*,'*ann*')
The query does return all the customers named Ann, but it doesn't return all the customers name Anne.
Is there a way to create prefix search on SQL Server 2008 using FTS?
I've found a solution to my problem.
The query should be:
select * from Customers where contains(*, '"ann*"')
The quotes are the important part.

Resources