Searching on file names with our standard search in EPiServer CMS 5 is not possible.
Standard the searchlocation just search in files if you want to search on file names as we do it in file manager is by using a UnifiedSearchQuery in a UnifiedSearchHitCollection.
The method PerformUnifiedFileSystemSearch() in SearchDataSource uses unified search query. The query has set FreeTextQuery to your search query. So it searches in files with your query but it got the fileNamePattern set to "*.*" which means your search query will never search for files=filenamepattern.
So you could workaround this by Inherit from SearchDataSource and override that method:
protected virtual IndexServerResults PerformUnifiedFileSystemSearch();
Thanks for your reply. Perhaps I should have posted this in the end user forum, as I am currently more involved with configuration of EPiServer sites rather than development, and I'm not familiar with the objects and methods you mention.
It does seem very strange to me that the very top field in the File Manager search is "File name" and yet it doesn't work as standard. Surely this is one of the very first things you would expect to be able to search on out of the box?
Sorry, I was abit too fast and missed that you actually wanted to search on files in the filemanager. But as mentioned we use a UnifiedSearchQuery in a UnifiedSearchHitCollection in the filemanager.
However about your issue with spaces in file names I've tested this and confirmed that it doesn't work. I will add this as an issue in our bug system.
12177: Can't search for file (via file name) with space in file name in the file manager
Many thanks for adding this to the bug list, and look forward to the fix!
Although this issue is somewhat fixed and available in CMS 6.0 (I realise this thread was started a long time ago), the solution is still not quite right, especially considering that the search service is using Lucene. I say this because you can only use certain search term modifiers in certain ways, as mentioned in this thread: http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=27603
You are able to search with <string>* and get results that match <string> at the beginning of the filename, but you cannot do *<string>. e.g. I have a filename brighton_leisure.jpg, I can find that with brighton*, but I can't find it with *leisure, which makes the feature a lot less usable, verging on useless when you have a lot of images, and even when you try to help the issue by categorising. In addition, ?s work e.g. brighton???????????? will match brighton_leisure.jpg (even brighton????????.jpg will match it) because there are the right number of question marks to match it, so again, this shows that only certain term modifiers are being used to search with.
Is there a reason why the other search term modifiers aren't available? And is there a solution? Or are we doing it wrong??
In my file manager (EPiServer 5.1.422.122) I have a file called "Test File.txt" which contains the word "hello".
I'm trying to search for the file in a number of ways, with varying results.
1. File name: Test File.txt - fail.
2. Search for text: hello - pass.
3. Search for text: hello AND File name: Test File.txt - fail.
4. Search for text: hello AND File name: *.txt - pass.
5. Search for text: hello AND File name: *File.txt -pass.
6. File name: *File.txt - fail
There's two things I notice about these results. Firstly EPiServer seems to have a problem searching for filenames with a space in - compare results 3 and 5.
Secondly, EPiServer will not find the file if you search on File name only, but will succeed if you search on File name AND Text - compare results 5 and 6.
Does anyone know what's going on here?