Yes you can. This is an example of how to filter away files by there extension
var result = client.Search<UnifiedFile>()
.Filter(x => !x.Extension.Match(".gif"))
If you never want to search for them, then best thing would to remove them at indexing time so they never enter the index. This could be done by setting up a convention for them.
FileIndexer.Instance.Conventions.ForInstancesOf<UnifiedFile>().ShouldIndex(x => !x.Extension.Equals(".gif"));
Hope that helps you.
Thanks Marcus, works fine!
Just out of curiousity, is there any particular reason you're doing Take(300)? In general you should only Take(Number_of_hits_that_should_be_displayed) and then do paging using using Skip(). That is,
var pageSize = 10;
var pageNum = //From query string or whatever
That way you won't be sending more data than needed over the wire and users will get snappier results. Then of course, sometimes there are exceptions.. :)
Well that was when I was much younger and before I knew how to filter out the bad extensions (gif, jpg etc) from the resultset directly in the request (as Marcus pointed out in this thread). So I did the filtering on my end, bad performance of course, and just a nasty workaround.
Now I know better, and I surely will only fetch the items I actually need.
But there could be exceptions... ;-)
How can I, in the search, easily filter out files that I do not want to get
I would like to exclude all jpg, gif, png files for example
Is it possible to add a .Filter() or something here?