We have a problem when trying to track queries that do not use the For() method, instead we use the Filter method. Please note that we are able to track queries that do use the For() method.
The documentation does not state that tracking won't work when not using the For() method, although all of their examples do make use of it, is this a known bug or feature for that matter?
The tracking is not very complete in it's solution, so you might have to do like we do and as I have written in this blog
Thank you for the quick reply Henrik, it is very much appreciated.
Will your example work for Find 1 R2, sorry I should have mentioned up front that we are using Find 1 R2? I don't seem to have access to the SearchClient.Instance.Statistics() method despite importing the EPiServer.Find.Framework.Statistics namespace. Also, we won't have a query input using the For() method, as their are multiple which we then map using the Filter() method.
Sample code (I have ommitted a couple of lines of code for clarity)
var query = SearchClient.Instance.Search<Custom_Page_Type_Here>();
query = query.Filter(x => x.CollegeCity.MatchCaseInsensitive(City));
query = query.Track();
Just for the sake of clarity, when we do not use the For() method, the query does not show up in the statistics feed in the EPiServer Find backend GUI. So I do have a similar problem that you stated in your blog post.
We have your ticket inquiry in our system and we deeply apologize for our delayed response. We are looking into it and hope to get an answer for you soon.
Hi,Tracking only works for the .For() extension simply since when using filters it is in the general case almost impossible to know what was the intended query string as you often add multiple filter statements. If you don't use .For() you have to manually track the query and to do that in Find 1.0.x you do that by calling StatisticsClient.Instance.Track((new TrackContext()).Id,"query", result.TotalMatching) (using the EPiServer.Find.Framework.Statistics.ForInternalUseOnly namespace);
Thank you, Richly.
Thanks Henrik, looks like that is what we will have to do. Henrik Fransas did give a similar example in the link that he provided, but wasn't compatible with Find 1 R2.
StatisticsClient.Instance.Track is not available in latest version.
Can I use track without for in latest version?
StatisticsClient.Instance has been moved to SearchClient.Instance.Statistics().No, what I said earlier is still true that if you want to track a query you need to use For() in order for the api to correclty find the intended querystring.
I had trouble finding SearchClient.Instance.Statistics(), I'm using Find version 12.4.1. For others that might get into the same situation, add the following namespaces:
using EPiServer.Find.Framework;using EPiServer.Find.Statistics;