Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Hi Fredrik,
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"))
.GetFilesResult();
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.
Hi Fredrik,
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
.Skip((pageNum-1)*pageSize)
.Take(pageSize);
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.. :)
Hi Joel,
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?
SearchClient.Instance.Search<UnifiedFile>(Language.Swedish)
.Take(300)
.GetResult();