R. Schreurs
2007-04-24 12:46:09 UTC
In a simple ASP.NET search page, I am offering users to enter search
terms and chooce one of the options And, Or, Exact search. I do not
want to bother them with the query language and will try to generate a
query in code. When searching with And option, the search terms are
split on white space and I create a Boolean search form that. If the
user searches, for instance, 'causes of death', the Query will be:
SELECT filename, vpath, doctitle, size, rank FROM SCOPE(' SHALLOW
TRAVERSAL OF "<path>" ') WHERE CONTAINS('causes AND of AND death')
ORDER BY rank DESC
This query will throw an exception:
"The query contained only ignored words."
ErrorCode -2147215867
Microsoft OLE DB Provider for Indexing Service
If the user changes the search terms to 'causes death', thus omitting
the stop word 'of', the query will be:
SELECT filename, vpath, doctitle, size, rank FROM SCOPE(' SHALLOW
TRAVERSAL OF "<path>" ') WHERE CONTAINS('causes AND death') ORDER BY
rank DESC
I will get a set of matches an no error.
Also, when the user specifies either of the search options Or or
Exact, he will not receive an exception. In these cases, the WHERE
clause will be CONTAINS('causes OR of OR death') or CONTAINS('"causes
of death"'), respectively.
I do not understand why the system throws an exception and I certainly
do not agree with the system when it is reporting the query only
contains ignored words.
What am I doing wrong? Should I modify the query syntax?
terms and chooce one of the options And, Or, Exact search. I do not
want to bother them with the query language and will try to generate a
query in code. When searching with And option, the search terms are
split on white space and I create a Boolean search form that. If the
user searches, for instance, 'causes of death', the Query will be:
SELECT filename, vpath, doctitle, size, rank FROM SCOPE(' SHALLOW
TRAVERSAL OF "<path>" ') WHERE CONTAINS('causes AND of AND death')
ORDER BY rank DESC
This query will throw an exception:
"The query contained only ignored words."
ErrorCode -2147215867
Microsoft OLE DB Provider for Indexing Service
If the user changes the search terms to 'causes death', thus omitting
the stop word 'of', the query will be:
SELECT filename, vpath, doctitle, size, rank FROM SCOPE(' SHALLOW
TRAVERSAL OF "<path>" ') WHERE CONTAINS('causes AND death') ORDER BY
rank DESC
I will get a set of matches an no error.
Also, when the user specifies either of the search options Or or
Exact, he will not receive an exception. In these cases, the WHERE
clause will be CONTAINS('causes OR of OR death') or CONTAINS('"causes
of death"'), respectively.
I do not understand why the system throws an exception and I certainly
do not agree with the system when it is reporting the query only
contains ignored words.
What am I doing wrong? Should I modify the query syntax?