Microsoft Desktop Search - CONTAINS not returning results on windows server 2008

∥☆過路亽.° 提交于 2020-01-02 08:53:07

问题


I am trying to search a remote fileshare (running windows server 2008 R2) for files that contain some text. If I try this, it works fine:

SELECT System.FileName
FROM RemoteServer.SystemIndex 
WHERE SCOPE='file://RemoteServer/FileShare'

and I get lots of results. But as soon as I try to search for some text I get no results:

SELECT System.FileName
FROM RemoteServer.SystemIndex 
WHERE SCOPE='file://RemoteServer/FileShare'
AND CONTAINS('a')

if I try it on my machine (Windows 7) it works fine:

SELECT FileName
FROM SystemIndex 
WHERE CONTAINS('a')

Here is my c# code that I'm using to search:

string connectionString = "Provider=Search.CollatorDSO;Extended Properties=\"Application=Windows\"";
using (OleDbConnection myOleDbConnection  = new OleDbConnection(connectionString))
{
    myOleDbConnection.Open();
    using (OleDbCommand myOleDbCommand  = new OleDbCommand(sql, myOleDbConnection))
    {
        using (myDataReader = myOleDbCommand.ExecuteReader())
        {
            if (!myDataReader.HasRows)
            {
                System.Console.WriteLine("Query returned 0 rows!");
            }
            else
            {
                // Process results here
            }
        }
    }
}

I have tried the following:

  • Rebuilt the index
  • Checked that the folder "FileShare" has been added on the server to be indexed
  • Checked the "File Types" tab, that the correct extensions are ticked, and that "Index Properties and File Contents" is selected for those extensions
  • Restarted the indexing service
  • Restarted the server itself

to no avail.

Any other suggestions? Frustrating as I'm 99% of the way there. This whole windows desktop search seems to be pretty unsupported, maybe I should bin it and use something else?


回答1:


Try declaring a nvarchar variable for the search word

DECLARE @SearchWord nvarchar(30) = 'a'

Then Modify your code to:

SELECT FileName

FROM SystemIndex

WHERE CONTAINS(@SearchWord)

This excerpt is from TechNet on CONTAINS See TechNet

*contains_search_condition* is nvarchar. An implicit conversion occurs when another character data type is used as input. In the following example, the @SearchWord variable, which is defined as varchar(30), causes an implicit conversion in the CONTAINS predicate.




回答2:


I meet the same problem. After serval days suffering trying, I found out this code that can run in windows server 2008 r2:

AND CONTAINS('keyword')
->
and System.Search.AutoSummary like '%keyword%'


来源:https://stackoverflow.com/questions/8827546/microsoft-desktop-search-contains-not-returning-results-on-windows-server-2008

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!