4

I have code in my project that uses Windows Search to look through file contents for a string I provide.

SELECT System.ItemName, System.ItemType, System.Search.Rank FROM SYSTEMINDEX 
WHERE SCOPE='file:C:/NiftyFolder' 
AND CONTAINS(System.Search.Contents,'"SEARCH STRING"')

I get the proper search results but I'd like to go a step further and get the context around my search string. I'm showing the search results on a webpage and ideally, I'd like something similar to what you get in Windows when you have the proper iFilters installed.

image showing context circled in orange

I've got the file type, path, and name but is there a System.??? that will get the text that's circled in orange in the image above?

Update: After more searching, it looks like it's not available.

http://social.msdn.microsoft.com/Forums/en-US/windowsdesktopsearchdevelopment/thread/1879e40f-bbf3-4365-b8f9-e0190ef437b0

http://social.msdn.microsoft.com/Forums/en-US/windowsdesktopsearchdevelopment/thread/ddd38a26-30a8-48f5-b053-dcee01094e2b

Windows Desktop Search not returning QueryFocusedSummary

The closest thing is System.Search.AutoSummary but it just returns the first 1000 or so text characters from the file.

Community
  • 1
  • 1
Curtis
  • 401
  • 4
  • 16
  • is this something that you are looking to use..? read over the page carefully there is something there about search highlights.. http://msdn.microsoft.com/en-us/magazine/cc163355.aspx – MethodMan Feb 14 '12 at 22:30
  • Look at adding this as well along with this link StringComparison.CurrentCultureIgnoreCase and This Link http://stackoverflow.com/questions/932156/get-context-for-search-string-in-text-in-c-sharp – MethodMan Feb 14 '12 at 22:32
  • The StringComparison.CurrentCultureIgnoreCase would be fine but I can't get the file contents from my search (I can't fully access System.Search.Contents). The only way I can think of to get to the contents would be to open the file on the file system and have it scan through that way... for each search result, that seems rather expensive. – Curtis Feb 24 '12 at 14:34
  • Regarding this http://msdn.microsoft.com/en-us/magazine/cc163355.aspx they are using hooking into Live Search or Sharepoint 2007 Search. I'm just querying the Windows Search index file so I don't have those available. – Curtis Feb 24 '12 at 14:37

0 Answers0