sitefinityluke

Sitefinity new Document SetBoost


I am collecting external data and then doing an ServiceBus.ResolveService<ISearchService>().UpdateIndex. This is working great but I wanted to SetBoost on the new Document. I have created an flag setboost with is using doc.SetBoost(1.5f); but I am getting a runtime error. Is this the correct way to set the boost score?

Severity Code Description Project File Line Suppression State Suppression State Error CS1061 'Document' does not contain a definition for 'SetBoost' and no accessible extension method 'SetBoost' accepting a first argument of type 'Document' could be found (are you missing a using directive or an assembly reference?)\

public static void ExternalIndexerAdd(ExternalIndexModel externalIndexer,boolean setBoost)
       {
            try
            {
                var fields = new List<IField>();

                var identityFld = new Field();
                identityFld.Name = "IdentityField";
                identityFld.Value = externalIndexer.IdentityField;
                fields.Add(identityFld);


                var titleField = new Field();
                titleField.Name = "Title";
                titleField.Value = externalIndexer.TitleField;
                fields.Add(titleField);


                var contentField = new Field();
                contentField.Name = "Content";
                contentField.Value = externalIndexer.ContentField;
                fields.Add(contentField);


                var linkField = new Field();
                linkField.Name = "Link";
                linkField.Value = externalIndexer.LinkField;
                fields.Add(linkField);

                var lastModifiedField = new Field();
                lastModifiedField.Name = "LastModified";
                lastModifiedField.Value = externalIndexer.LastModifiedField;
                fields.Add(lastModifiedField);

                var doc = new Document(fields, String.Format("{0}", "IdentityField"));

                if (SetBoost == true){
                    doc.SetBoost(1.5f);
                }

                ServiceBus.ResolveService<ISearchService>().UpdateIndex("nccn-search-index", new List<IDocument>() { doc });
            }
            catch (Exception ex)
            {
               
            }
       }

Solution

  • In order to accomplish this I believe you will need to customize the search scoring of Sitefinity's lucene search index. Here is the search API available: https://www.progress.com/documentation/sitefinity-cms/for-developers-customize-the-lucene-search-scoring