开发者

Trying to exclude VTI* paths in MSIDXS sql select statement

using a c# asp.net page, building a SQL query stri开发者_运维技巧ng to run against an index server catalog:

string SQL = "SELECT doctitle, vpath, Path, Write, Size, Rank ";
    SQL += "FROM \"" + strCatalog + "\"..SCOPE() ";
    SQL += "WHERE";
    SQL += " CONTAINS(Contents, '" + strQP + "') ";
    SQL += "AND NOT CONTAINS(Path, '\"_vti_\"') ";
    SQL += "AND NOT CONTAINS(FileName, '\".ascx\" OR \".config\" OR \".css\"') ";
    SQL += "ORDER BY Rank DESC"; 

Seems to work fine, except it will return results in the _vti_ directories which I am trying to avoid.

Edit: All but asked question, so to be technical: How can I search the index and have it not return files from the vti folders? Switching to use an ixsso query object is possible, but i'd rather avoid it for this particular instance.


Ok, I gave up on above code, switching to a LIKE vs CONTAINS clause worked.

SQL += "AND NOT CONTAINS(Path, '\"_vti_\"');

replaced with:

SQL += " AND Path NOT LIKE '%vti%' ";

Seems to have done the trick. The advantage of CONTAINS in this context is that it will search all indexed fields (as in the next line), but since im just weeding out directories it seems searching Path variable is suitable. I was also able to add to it without trouble:

SQL += " Path NOT LIKE '%vti%' AND Path NOT LIKE '%icons%' ";

So in theory i can build a quick filter of hits to exclude seemingly easy. I just wish there were more documentation on the MSIDXS stuff. Blah.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜