a***@gmx.net
2007-02-06 13:34:27 UTC
I'm indexing the contents of a folder with the Microsoft Indexing
Service which builds a catalog. For simplicification in that folder
are only *.txt-Files. With a simple ASP page I query the catalog,
means I can search for a specific textfile in which the searched
string can be found.
In the line: "searchstring =" you just type the desired string you are
looking for and call the this asp-page, for example:
http://localhost/search.asp
The script will show you all documents (textfiles) that contain the
searchstring.
(Look at this working script first, below it my question will follow)
search.asp:
//-----------------------------------------------------------------------
<html>
<head>
<title>
Search Results
</title>
</head>
<body>
<%
' This section sets the various configuration variables
pagesize = 5000
maxrecords=5000
searchstring="Hotline"
catalogtosearch="TestCatalog"
searchrankorder="rank[d]"
origsearch=searchstring
%>
<%
'This section performs the query
dim q
dim util
set q=server.createobject("ixsso.query")
set util=server.createobject("ixsso.util")
q.query=searchstring
q.catalog=catalogtosearch
q.sortby=searchrankorder
q.columns="doctitle, filename, size, write, rank, directory, path"
q.maxrecords=maxrecords
%>
<%
'This section displays the results
set rs=q.createrecordset("nonsequential")
rs.pagesize=pagesize
response.write"<p>Your search for <b>" & origsearch & "</b> produced "
if rs.recordcount=0 then response.write "no results"
if rs.recordcount=1 then response.write "1 result: "
if rs.recordcount>1 then response.write(rs.recordcount) & " results: "
%>
<table border=1><tr><td><b>Title</b></td><td><b>Filename</b></
td><td><b>Date /
Time</b></td><td><b>Size</b></td><td><b>Relevance</b></
td><td><b>Directory</b></td></tr>
<%
do while not rs.EOF
response.write "<tr><td>" & rs("doctitle") & "</td><td>" & "<a href="
& "'" & rs("path") & "'" & ">" & rs("filename") & "</a>" &
"</td><td>" & rs("write") & "</td><td>" & rs("size") & "</td><td>" &
rs("rank") & "</td><td>" & rs("directory") & "</td></tr>"
rs.movenext
loop
response.write "</table>"
set rs=nothing
set q=nothing
set util=nothing
%>
</body>
</html>
//-----------------------------------------------------------------------
As you can see, I defined the searchstring simple like this:
searchstring="Hotline"
Means the script will find all textfiles that have somewhere "Hotline"
inside them (and this really works).
The Index Server now has it's own query language, for Index Server
3.x
by default the query dialect 2 is used. With that dialect it should be
possible
to query following examples:
$CONTENTS ppdev visual basic
-> Find all documents which contain at least one of the 3 words above
@CONTENTS ppdev visual basic
-> Find all document which contain the string "ppdev visual basic"
$CONTENTS ppdev AND visual AND basic
-> Find all documents which contain all 3 words above (no matter in
what order)
With that knowledge it should now be possible to search for textfiles
that contain for example "Microsoft" and "Hotline" in them, therefore
I
changed my searchstring to:
searchstring="$CONTENTS Microsoft AND Hotline"
If you execute the script, it will really find now all documents that
contain "Microsoft" and "Hotline" in them (everything ok so far...)
Now what I don't understand is, if you specify the searchstring like
this:
searchstring="$CONTENTS Microsof AND Hotline"
the Indexserver won't return any results anymore?
In the Index Query Language Wildcards should be supported,
but also if you query like:
searchstring="$CONTENTS Microsof* AND Hotline"
or
searchstring="$CONTENTS Microsof? AND Hotline"
the Indexserver still won't return any results...
Does anybody have an idea why this doesn't work?
If found an interesting which mention similar problems:
http://www.aimingtech.com/file_searching.htm
(Look at the section "Undocumented Surprises in Indexing Service")
There they write that you should add "& #size>0" to your query,
therefore I tryed it like this too:
searchstring="$CONTENTS Microsof* AND Hotline AND #size>0"
(Note that "AND" and "&" are the same...)
I also tryed like this:
searchstring="$CONTENTS Microsof* AND Hotline AND #size > 0"
and also like this:
searchstring="$CONTENTS Microsof* AND Hotline AND @size>0"
(I guess they wrote it wrong in that site with #size, it should be
@size normally..)
Still the IndexServer doesn't return any results, it only returns
results if I write
searchstring="$CONTENTS Microsoft AND Hotline AND @size > 0"
or simply
searchstring="$CONTENTS Microsoft AND Hotline"
I've found another interesting article that adresses the wildcard
topic:
http://support.microsoft.com/kb/320942/en-us
So what I tryed is that I adjusted my script above like this:
<%
'This section performs the query
dim q
set q=server.createobject("ixsso.query")
q.query=searchstring
q.dialect = 1
q.catalog=catalogtosearch
q.sortby=searchrankorder
q.columns="doctitle, filename, size, write, rank, directory, path"
q.maxrecords=maxrecords
%>
And the searchline I set again to:
searchstring="$CONTENTS Microsof* AND Hotline"
Still I don't get any results back
(even there is for SURE a textfile indexed that holds both of the
searched words...)
When you search on the Internet, you always find a lot of exmaples
with a simple searchstring like
searchstring="Hotline"
But I didn't find anything that explains me why I can't search for
searchstring="$CONTENTS Microsof AND Hotline"
or
searchstring="$CONTENTS Microsof* AND Hotline"
Anybody around with a hint for me?
Service which builds a catalog. For simplicification in that folder
are only *.txt-Files. With a simple ASP page I query the catalog,
means I can search for a specific textfile in which the searched
string can be found.
In the line: "searchstring =" you just type the desired string you are
looking for and call the this asp-page, for example:
http://localhost/search.asp
The script will show you all documents (textfiles) that contain the
searchstring.
(Look at this working script first, below it my question will follow)
search.asp:
//-----------------------------------------------------------------------
<html>
<head>
<title>
Search Results
</title>
</head>
<body>
<%
' This section sets the various configuration variables
pagesize = 5000
maxrecords=5000
searchstring="Hotline"
catalogtosearch="TestCatalog"
searchrankorder="rank[d]"
origsearch=searchstring
%>
<%
'This section performs the query
dim q
dim util
set q=server.createobject("ixsso.query")
set util=server.createobject("ixsso.util")
q.query=searchstring
q.catalog=catalogtosearch
q.sortby=searchrankorder
q.columns="doctitle, filename, size, write, rank, directory, path"
q.maxrecords=maxrecords
%>
<%
'This section displays the results
set rs=q.createrecordset("nonsequential")
rs.pagesize=pagesize
response.write"<p>Your search for <b>" & origsearch & "</b> produced "
if rs.recordcount=0 then response.write "no results"
if rs.recordcount=1 then response.write "1 result: "
if rs.recordcount>1 then response.write(rs.recordcount) & " results: "
%>
<table border=1><tr><td><b>Title</b></td><td><b>Filename</b></
td><td><b>Date /
Time</b></td><td><b>Size</b></td><td><b>Relevance</b></
td><td><b>Directory</b></td></tr>
<%
do while not rs.EOF
response.write "<tr><td>" & rs("doctitle") & "</td><td>" & "<a href="
& "'" & rs("path") & "'" & ">" & rs("filename") & "</a>" &
"</td><td>" & rs("write") & "</td><td>" & rs("size") & "</td><td>" &
rs("rank") & "</td><td>" & rs("directory") & "</td></tr>"
rs.movenext
loop
response.write "</table>"
set rs=nothing
set q=nothing
set util=nothing
%>
</body>
</html>
//-----------------------------------------------------------------------
As you can see, I defined the searchstring simple like this:
searchstring="Hotline"
Means the script will find all textfiles that have somewhere "Hotline"
inside them (and this really works).
The Index Server now has it's own query language, for Index Server
3.x
by default the query dialect 2 is used. With that dialect it should be
possible
to query following examples:
$CONTENTS ppdev visual basic
-> Find all documents which contain at least one of the 3 words above
@CONTENTS ppdev visual basic
-> Find all document which contain the string "ppdev visual basic"
$CONTENTS ppdev AND visual AND basic
-> Find all documents which contain all 3 words above (no matter in
what order)
With that knowledge it should now be possible to search for textfiles
that contain for example "Microsoft" and "Hotline" in them, therefore
I
changed my searchstring to:
searchstring="$CONTENTS Microsoft AND Hotline"
If you execute the script, it will really find now all documents that
contain "Microsoft" and "Hotline" in them (everything ok so far...)
Now what I don't understand is, if you specify the searchstring like
this:
searchstring="$CONTENTS Microsof AND Hotline"
the Indexserver won't return any results anymore?
In the Index Query Language Wildcards should be supported,
but also if you query like:
searchstring="$CONTENTS Microsof* AND Hotline"
or
searchstring="$CONTENTS Microsof? AND Hotline"
the Indexserver still won't return any results...
Does anybody have an idea why this doesn't work?
If found an interesting which mention similar problems:
http://www.aimingtech.com/file_searching.htm
(Look at the section "Undocumented Surprises in Indexing Service")
There they write that you should add "& #size>0" to your query,
therefore I tryed it like this too:
searchstring="$CONTENTS Microsof* AND Hotline AND #size>0"
(Note that "AND" and "&" are the same...)
I also tryed like this:
searchstring="$CONTENTS Microsof* AND Hotline AND #size > 0"
and also like this:
searchstring="$CONTENTS Microsof* AND Hotline AND @size>0"
(I guess they wrote it wrong in that site with #size, it should be
@size normally..)
Still the IndexServer doesn't return any results, it only returns
results if I write
searchstring="$CONTENTS Microsoft AND Hotline AND @size > 0"
or simply
searchstring="$CONTENTS Microsoft AND Hotline"
I've found another interesting article that adresses the wildcard
topic:
http://support.microsoft.com/kb/320942/en-us
So what I tryed is that I adjusted my script above like this:
<%
'This section performs the query
dim q
set q=server.createobject("ixsso.query")
q.query=searchstring
q.dialect = 1
q.catalog=catalogtosearch
q.sortby=searchrankorder
q.columns="doctitle, filename, size, write, rank, directory, path"
q.maxrecords=maxrecords
%>
And the searchline I set again to:
searchstring="$CONTENTS Microsof* AND Hotline"
Still I don't get any results back
(even there is for SURE a textfile indexed that holds both of the
searched words...)
When you search on the Internet, you always find a lot of exmaples
with a simple searchstring like
searchstring="Hotline"
But I didn't find anything that explains me why I can't search for
searchstring="$CONTENTS Microsof AND Hotline"
or
searchstring="$CONTENTS Microsof* AND Hotline"
Anybody around with a hint for me?