Skip to content

Extract terms from Luceneindex (if you want to make a searchword helper)

License

Notifications You must be signed in to change notification settings

rpjengaard/SkybrudLuceneTermExtractor

Repository files navigation

Skybrud.Lucene.TermExtractor is a small library to extract terms from an Umbraco Lucene Index. You can use it, if you for example, want to make a auto-suggestion-searchword function on your website (ala https://twitter.github.io/typeahead.js/).

The library creates a .json file with an array of terms in the /App_Data/ folder, which you can use with fx typeahead.js (https://twitter.github.io/typeahead.js/). The terms-array is made out of the lucene-fields you set up in the FieldNames property.

IndexPath: The path to the Lucene index (default is /App_Data/TEMP/ExamineIndexes/External/Index/).
FieldNames: An array of fieldsnames you want to extraxt terms from.

You can also set an rootId (nodeId) from where to start if you have multiple sites and set min-length on the words to extract.

Install From NuGet

https://www.nuget.org/packages/Skybrud.Lucene.TermExtractor/

Example Controller to save .json file

namespace skybrud.Controllers
{
    public class SiteSearchApiController : UmbracoApiController
    {
        [HttpGet]
        public void SaveToJson(int rootId, int minLength)
        {
            var lte = new Skybrud.Lucene.Term.Extractor
            {
                IndexPath = "/App_Data/TEMP/ExamineIndexes/External/Index/",
                FieldNames = new string[] { "nodeName", "teaser" }
            };
            
            lte.SaveToJson(rootId, minLength);
        }
    }
}

About

Extract terms from Luceneindex (if you want to make a searchword helper)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages