Jump to content

"MinSimilarityScore"


chef

Recommended Posts

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 by chef
Link to comment
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...