I am trying to query the Windows Search index programmatically using the Windows Search SQL Syntax
I am able to search file contents in my C# winforms application using the search query below:
string strSearchQuery =
"SELECT System.ItemName FROM SystemIndex " +
"WHERE scope ='file:" + @"C:\myfolder\" +
"' and FREETEXT('dummy')";
ISSUE: However, I am not able to use this query to search for part of a word in the file contents.
For example: If a file (such as a .txt file) contains the the text "abcd", and I search for FREETEXT('ab')
, it doesn't show that file.
I have tried using:
FREETEXT('ab')
FREETEXT('*ab*')
FREETEXT('\"ab\"')
FREETEXT('\"*ab*\"')
FREETEXT('*\"ab\"*')
FREETEXT('ab*')
FREETEXT('\"*ab*\"')
FREETEXT('\"ab\"*')
I've also tried using CONTAINS
with the above combinations instead of FREETEXT
.
When I search for ab
directly on Windows search, it shows the file having the text
How can I modify this query to search for a part of a word in the file contents? Please help!