Try Now
More in this section

Forums / Developing with Sitefinity / Internal Search

Internal Search

2 posts, 0 answered
  1. chris
    chris avatar
    1 posts
    20 Sep 2010
    21 Sep 2010
    Link to this post
    Picking up Sitefinity for the first time for a client's project and have an interesting task laid out for me. For now, the question I have has to do with Sitefinity's ability to do an internal (within the code only) search. I assume it is capable of this, but frankly the API listing is enormous and isn't documented thoroughly enough to make searching it of much use. Effectively, we are trying to change an article listing based off several incoming RSS feeds, seeking out news articles within the CMS that are relevant to keywords extracted from the feeds.

    I am simply trying to determine how this would be done in interfacing with the search, that is the first key-stone to starting into this project. How robust is Sitefinity's search engine and how tightly can its searches be refined? And above all else, what are the calls and commands (or at least the classes, so I can dig them out of the API) that are used to execute a site-search. Also, a little more thorough information on that API information would be nice... (i.e. more than just "This is the name of the function and what you have to pass it.")

    Thanks for your time.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    25 Oct 2016
    21 Sep 2010
    Link to this post
    Hello chris,

    Sitefinity uses Lucene .NET Search Engine. There is a class SearchManager which wraps the data access functions of the SiteFinity search module. The class has a static method Search that we use to retrieve data from Lucene segment files.

    Search(string searchQuery, string indexName, int startIndex, int max, string mode, bool escapeChars, out int totalItems) - Searches a given search index for matching results, utilizing the Lucene search engine

    • "searchQuery" > The search query e.g.(sitefinity "search query")
    • "indexName" > The name of the index to search into e.g.("ProductsIndex")
    • "startIndex" > start index for paging i.e.(starting index of the displayed documents)
    • "max" > max results per page
    • "mode" > Sets the query parser operator (if mode is equal to "AnyWord" the default operator becomes OR otherwise is AND)
    • "escapeChars" > Specifies if special characters should be escaped and thus becoming part of the search term(s)
    • "totalItems" > The total number of hits for the search query
    There are two public controls SearchBox  - it is used for setting SearchIndex that will be used by SearchResult control

    SearchRestult control - reads QueryString data passed by SearchBox and calls the static method of SearchManager class. Then inside CreateChildControls of this control we create a generic list of ResultItem object. The result item object has the following properties.

    Title-  Gets or set the title of a document.
    Snippet - Gets or set a snippet of the content of a document.
    Url -Gets or set a URL for the document.
    Score - Gets or sets the score for this document within a result set.

    You can trigger the index programmatically by using Index method 9rates an index for all pages and documents provided by all registered clients) of IndexingService class. This class implements IIndexingService interface and it is used to represent services defined in the application configuration.

    You can also take a look at

    We form the result items based on Telerik.Lucene.Net.Highlight.Highlighter which is used to markup highlighted terms found in the best sections of a text, Fragmenter,  Scorer,  Formatter, Encoder and tokenizers. The actual segment is created by Lucene and we get the best fragments from there  by using Telerik.Lucene.Net.Highlight.GetBestFragment method - highlights chosen terms in a text, extracting the most relevant sections.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered