chef 3745 Posted February 23, 2021 Share Posted February 23, 2021 (edited) Hi, Working with the "SimilarTo" param in an ItemQuery, I am stumped because I'm not getting any results back. It is always 0. I see there is also "MinSimilarityScore", and I am wondering if this is necessary to get results from the query? I expect that the code below would return 3 items that are similar to the item passed into the query, and that they would be of the same type, based on the Administrators account. But it is 0.... Swaggers: "/Items/{Id}/Similar" it works okay. public List<BaseItem> GetSimilarItems(BaseItem item) { var users = UserManager.Users; var administrator = users.FirstOrDefault(u => u.Policy.IsAdministrator); var similarQuery = LibraryManager.QueryItems(new InternalItemsQuery(administrator) { SimilarTo = item, MinSimilarityScore = 1, // ??????? how high should this number be ???? Limit = 3, Recursive = true, IncludeItemTypes = new[] { item.GetType().Name } }); ServerController.Instance.Log.Info($"SIMILAR ITEMS HAS {similarQuery.TotalRecordCount} Items"); return similarQuery.Items.ToList(); } Edited February 23, 2021 by chef Link to comment Share on other sites More sharing options...
Luke 37049 Posted February 23, 2021 Share Posted February 23, 2021 Hi, no, I would suggest not setting it. Then you'll get consistent results with what the UI is doing. Link to comment Share on other sites More sharing options...
chef 3745 Posted February 23, 2021 Author Share Posted February 23, 2021 Just now, Luke said: Hi, no, I would suggest not setting it. Then you'll get consistent results with what the UI is doing. Weird! Once I removed the "Limit" param I got results. I double checked, and added "Limit" back to the query, it didn't work again. This is okay because I can just ".Take(3)". Is that by design? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now