[英]Error running windows search query on remote machine from C#
When I try to execute the following OLEDB command to programmatically query a search index on a remote machine (ALEC-HP) on the same domain I get the following error message 当我尝试执行以下OLEDB命令以编程方式查询同一域上远程计算机(ALEC-HP)上的搜索索引时,出现以下错误消息
Unspecified error: -2147219688(0x80040718)
未指定的错误:-2147219688(0x80040718)
On the local machine the share \\\\ALEC-HP\\Simon.ALEKATEST.000
can be seen OK 在本地计算机上,共享
\\\\ALEC-HP\\Simon.ALEKATEST.000
可以看到正常
SELECT System.ItemNameDisplay,SYSTEM.ITEMURL,System.DateModified,
System.ItemName, System.Search.Rank, System.Keywords,
System.Search.AutoSummary,System.Search.GatherTime, System.ItemType
FROM ALEC-HP.SystemIndex
WHERE Scope='file://ALEC-HP/Simon.ALEKATEST.000'
AND CONTAINS(*,'"April Dwyer"',1033)
If the query is simplified to 如果查询简化为
SELECT System.ItemNameDisplay,SYSTEM.ITEMURL,System.DateModified,
System.ItemName, System.Search.Rank, System.Keywords,
System.Search.AutoSummary,System.Search.GatherTime, System.ItemType
FROM ALEC-HP.SystemIndex
WHERE CONTAINS(*,'"April Dwyer"',1033)
The same error occurs. 发生相同的错误。
The query on the local index 查询本地索引
SELECT System.ItemNameDisplay,SYSTEM.ITEMURL,System.DateModified,
System.ItemName, System.Search.Rank, System.Keywords,
System.Search.AutoSummary,System.Search.GatherTime, System.ItemType
FROM "SYSTEMINDEX"
WHERE CONTAINS(*,'"April Dwyer"',1033)
runs OK. 运行正常。 Rebuilding the search index on ALEC-HP doesn't help.
在ALEC-HP上重建搜索索引没有帮助。
The remote machine ALEC-HP runs Windows 7 and local search works OK on that machine. 远程计算机ALEC-HP运行Windows 7,并且本地搜索在该计算机上工作正常。
Problem has now appeared on the search index of a remote machine running Win 8.1 现在,在运行Win 8.1的远程计算机的搜索索引上出现了问题
For queries on a remote machine, the scope='File:UNCPath'
clause must contain a UNC Path which is shared with the local machine (the path can use either forward or back slashes). 对于在远程计算机上的查询,
scope='File:UNCPath'
子句必须包含与本地计算机共享的UNC路径(该路径可以使用正斜杠或反斜杠)。 Ie: 即:
AND SCOPE='file://server/shareName'
If the path is not visible to the local machine, or the scope absent then the Unspecified Error appears. 如果该路径对本地计算机不可见,或者该范围不存在,则出现“未指定错误”。 A more informative error message would be helpful!
更详尽的错误消息会有所帮助!
ps Accessibility of the UNC Path from the local machine is not the whole story. ps UNC路径从本地计算机的可访问性不是全部。 On the remote machine the search location list includes the My Documents folders in two profile folders folder, which are both shared and have the same permissions for SYSTEM, which is the account used to run remote search.
在远程计算机上,搜索位置列表包括两个配置文件文件夹文件夹中的“我的文档”文件夹,这两个文件夹是共享的,并且对SYSTEM(运行远程搜索的帐户)具有相同的权限。 The share permissions are the same, but when one of the profile folders is used in the scope parameter, the Undefined Error appears.
共享权限是相同的,但是在scope参数中使用了一个配置文件文件夹时,将出现“未定义错误”。 Search functions as expected for the other profile folder.
搜索功能与其他配置文件文件夹一样。
The error code 0x80040718 can be found in WindowsSearchErrors.h
. 错误代码0x80040718可以在
WindowsSearchErrors.h
找到。 It corresponds to: 它对应于:
QRY_E_INVALIDSCOPES
The scopes specified for the query were incorrectly formatted.
If you want to search the local catalog of another computer you must : 如果要搜索另一台计算机的本地目录,则必须 :
From MSDN: SCOPE and DIRECTORY Predicates 从MSDN: 范围和目录谓词
To query the local catalog of a remote computer, include the computer name before the catalog and a Universal Naming Convention (UNC) path on the remote computer in the SCOPE or DIRECTORY clause.
若要查询远程计算机的本地目录,请在目录之前添加计算机名称,并在SCOPE或DIRECTORY子句中包括远程计算机上的通用命名约定(UNC)路径。
You can find more information in Querying Process in Windows Search 您可以在Windows搜索的查询过程中找到更多信息。
Local and Remote Queries
本地和远程查询
You can execute your queries either locally or remotely.
您可以在本地或远程执行查询。 A local query using the FROM clause is shown in the following example.
以下示例显示了使用FROM子句的本地查询。 A local query queries the local SystemIndex catalog only.
本地查询仅查询本地SystemIndex目录。
FROM SystemIndex
A remote query using the FROM clause is shown in the following example.
以下示例显示了使用FROM子句的远程查询。 Adding ComputerName transforms the previous example into a remote query.
添加ComputerName将前面的示例转换为远程查询。
FROM [<ComputerName>.]SystemIndex
To retrieve an item by remote query, the item must meet the following requirements:
要通过远程查询检索项目,该项目必须满足以下要求:
- Be accessible via Universal Naming Convention (UNC) path.
可通过通用命名约定(UNC)路径访问。
- Exist on the remote computer to which the client has access.
存在于客户端可以访问的远程计算机上。
- Have its security set to allow the client to have Read access.
设置其安全性以允许客户端具有读取访问权限。
After you share the folder(s), you can query the local index by specifying the remote computer's machine name in the FROM clause, and a UNC path on the remote computer in the SCOPE clause.
共享文件夹后,可以通过在FROM子句中指定远程计算机的计算机名称,并在SCOPE子句中指定远程计算机的UNC路径来查询本地索引。 A remote query using the FROM and SCOPE clauses is shown in the following example.
以下示例显示了使用FROM和SCOPE子句的远程查询。
SELECT System.ItemName FROM MachineName.SystemIndex WHERE SCOPE='file://MachineName/<path>'
And the page URL Formatting Requirements documents some other variations for SQL for remote queries: “ URL格式要求 ”页面记录了用于远程查询的SQL的其他一些变体:
file:///c:\\test\\example\\
file:///c:\\test\\example\\
file:c:/test/example/
file:c:/test/example/
c:\\test\\example\\
c:\\test\\example\\
file:///\\\\server\\share\\
file:///\\\\server\\share\\
file://server/share/
file://server/share/
\\\\server\\share\\
\\\\server\\share\\
This means that: 这意味着:
For example: 例如:
SELECT System.ItemNameDisplay
FROM "ALEC-HP".SystemIndex
WHERE SCOPE='file://ALEC-HP/Simon.ALEKATEST.000'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.