473,416 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Full Text File Search with Indexing Service on Windows

Here's a short tutorial on how to the OLE-DB extension to access
Windows Indexing Service. Impress your office-mates with a powerful
full-text search feature on your intranet. It's easier than you think.

First, download and install the extension
(http://sourceforge.net/project/showf...age_id=198554).
Simply unzip the file and copy the correct version of php_oledb.dll
into the PHP extensions folder. Then add the line
extension=php_oledb.dll in php.ini and restart your web server.

Now, if Indexing Service isn't running on your computer, turn it on. Go
to Control Panel Administrative Tools Services and configure
Indexing Service to start automatically. You can also ask the little
dog in the search window to do it for you if you're using Windows XP.
You will need to wait a while for Windows to build the initial index.
It could take a couple hours.

Once the extension is installed and the index is ready, you can start
coding. To connect to Indexing Service, you use the oledb_open
function:

$link = oledb_open("Provider=MSIDXS");

You then call oledb_query with a SQL statement. Let us start with
something simple: We'll look for all files on the computer containing
the word "love":

$keyword = 'love';
$sql = "SELECT filename, size, path
FROM SCOPE()
WHERE CONTAINS(Contents, '$keyword')";
$res = oledb_query($sql, $link);
while($row = oledb_fetch_assoc($res)) {
var_dump($row);
}

An example among the many results I get on my computer:

array(3) {
["FILENAME"]=>
string(11) "ap_config.h"
["SIZE"]=>
int(38787)
["PATH"]=>
string(56) "c:\program files\apache group\apache\include\ap_config.h"
}

Instead of a table name we're retrieving rows from SCOPE(), which
determines which directories are searched. When there's nothing inside
the parenthese, all matching files in the catalogs are returned. To
search a particular directory, we put in 'DEEP TRAVERSAL OF <dir>' or
'SHALLOW TRAVERSAL OF <dir>'.

To search for files in C:\htdocs:

$dir = 'C:\\htdocs'
$keyword = 'love';
$sql = "SELECT filename, size, path
FROM SCOPE('DEEP TRAVERSAL OF \"$dir\"')
WHERE CONTAINS(Contents, '$keyword')";
$res = oledb_query($sql, $link);

Deep traversal means sub-directories are searched, while shallow
traversal means they're not.

There are many fields about a file that you can search on and retrieve.
To see what they are, right click on My Computer and select Manage. In
the Computer Management window, expand Services and Applications, then
Index Service, then System, and select Properties. The names listed
under Friendly Names are the ones you can use in your statement.

Anyway, it's getting late. I'll talk more about this tomorrow :-)

Aug 17 '06 #1
0 4193

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kellygreer1 | last post by:
Hello group, Does anyone know how near a word needs to be to another word to be included in the results of a CONTAINS search that uses NEAR? Is this setting adjustable? Is is stored in the...
2
by: Samuel R. Neff | last post by:
What options are available for doing full-text searches of database data without using a database-specific full-text engine? The only option I've found is Google's Search Appliance but it's an...
5
by: Mantorok | last post by:
Hi Can anyone advise me on how I can get my asp.net site to be searchable from search sites such as Google? I have absolutely no idea where start, where to go to get the site involved in...
1
by: jrs_14618 | last post by:
Hello All, This post is essentially a reply a previous post/thread here on this mailing.database.myodbc group titled: MySQL 4.0, FULL-TEXT Indexing and Search Arabic Data, Unicode I was...
3
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and...
8
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
Hi; I copied a new set of files over to my ASP.NET dir (and subdirs) on our test server. This replaced every file for the app. When I first then tried to bring it up, I got the below error. ...
0
by: rclark30 | last post by:
Hello to everyone out there. I am a non SQL person TRAPPED in a nightmare! The long short is we have a CRM 3.0 database that is running in SQL 2005 on a Windows 2003 SP1 Server. (HP ProLiant ML350...
8
by: Sham | last post by:
I am trying to perform the following query on a table that has been indexed using Full Text Search. The table contains multiple columns than have been indexed. (Below, all xml columns are...
0
by: Mark112 | last post by:
Hi I am attempting to restore the search feature that was created by an external company using the indexing service for our intranet. the intranet is located locally at each of our offices. The...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.