Assembly: Search

Smartsite 7.10 - ...


Classes in assembly Smartsite.EnterpriseSearch.Search can be used to implement a search application in a .net environment. The assembly is available for .net 4.8 and .net 6.0.

Search classes

Query classes

Query classes are used to specify a search query. Use objects, methods and properties as usual for .net. Each class can produce .json corresponding to the query, which is used to build the .json for a complete query. The complete query is sent to Elastic Search in order to perform an actual search.

Classes for the query components of a complete query mimic as much as possible query components as used by Elastic Search.

For a search application there is no need to use query components to build-up a complete query; this is done by class SearchQuery, see below. Query component classes are a preparation for searches that require full control over the search approach. 

Name Purpose
BaseQuery Abstract base class for parts of the search query.
BoolQuery Boolean compound query. It contains a set of must-queries, a set of should-queries, and a set of must-not-queries.
MultiMatchQuery Query that uses the search words for a search in multiple fields of a document, for example to search "test" in fields doc_title and doc_body.
NestedQuery Query to wrap a query, in order to apply the query to nested documents. The nested query has no 1:1 counterpart in Elastic Search. It is an Enterprise Search implementation to search documents in a mini hierarchy of documents, and to find the root document of the hierarchy.
RangeQuery Query for a range of values in a field. The general range query is currently not supported. Instead the class implements the specialized date range query, applied to document field doc_created.
TermQuery Query that uses a term to filter, given a field of a document, for example to filter on a keyword given field doc_keywords.
TermsQuery Query that uses multiple terms to filter, given a field of a document, for example to filter on keywords given field doc_keywords. The filter matches if one or more terms match.

Enumerations supporting the query classes:

Name Purpose
BoolQueryOccurrenceType Enumeration of the above boolean query occurrence types: Must, Should and MustNot.
MultiMatchQueryType Enumeration of the multi-match query types: BestFields for a regular search, Phrase to match an entire field, PhrasePrefix to match a prefix in the field, PhraseSuffix to match a suffix in the field. PhraseSuffix has no 1:1 counterpart in Elastic Search. It is an Enterprise Search implementation that uses a PhrasePrefix, applied to the reverse of words.

Aggregation classes

Aggregation specifications can be added to the search specification:

  • in order to request aggregation counts, in addition to the search result itself,
  • and optionally in order to request to filter the search result given aggregation values.

The search application uses aggregations to implement facets and facetted search.

Name Purpose
SearchQueryBaseAggregation Abstract base class for search query aggregations.
SearchQueryDateRangeAggregation Aggregation resulting in one bucket per specified date range. This is applied to field doc_created by default.
SearchQueryTermsAggregation Aggregation resulting in one bucket per unique term, limited to the number of buckets.
SearchQueryAggregation Deprecated class. Use SearchQueryTermsAggregation instead.

Support for the aggregation classes:

Name Type Purpose
SearchQueryAggregationType enum Enumeration of aggregation types: Terms, Cardinality or DateRange. This enumeration will be revoked, differentiating between types by means of class types such as SearchQueryTermsAggregation and SearchQueryDateRangeAggregation.
SearchQueryDateRange class One date range for use by class SearchQueryDateRangeAggregation. Includes a from-date specification and/or to-date specification. Date specifications support date math as supported by Elastic Search.

In addition to requesting aggregations it is possible to add filter values to the aggregation, requesting to keep the search results that match the filter values. 

Name Purpose
BaseFilterValue Abstract base class for a filter value.
DateRangeFilterValue Filter value containing a from-date specification and/or containing a to-date specification. This is applied to field doc_created by default. Multiple date range filter values are possible, handled as an OR.
TermFilterValue Filter value containing a term, or more generally a string. Multiple term filter values are possible, handles as an OR.

Presentation classes

A few classes allow to control the presentation of the search result.

Name Purpose
SortParameter Specification of a field for result ordering, and whether this should be ascending or descending.
HighlightRequest Specifies how to highlight found text in search result fragments.

Searcher classes

The Searcher class performs an actual search. In order to perform the search it requires a search query and it requires the list of Elastic Search indexes to search.

Name Type Purpose
SearchField class Specification of one document field to search and, for example, which weight to apply.
SearchFieldType enum Enumeration of search field types: FullText, ValueOfField or ValuesWithinField. This has no counterpart in Elastic Search. It is an Enterprise Search implementation to express the intent how the field should be used to search, and this steers how parts of the .json search query are built.
SearchQuery class Builds and represents the complete search query. This includes the list of fields to search, aggregations, result ordering, result highlighting, paging and more.
Searcher class Accepts the search query and performs the actual search by sending the .json search specification to Elastic Search. Captures the search result and returns this result to the search application.

Result classes

Search result classes

Result classes are used to return the search result to the search application. Class Searcher captures the .json search result as returned by Elastic Search, and converts this to result class instances representing the search result. 

Name Type Purpose
SearchResultEntry class Represents one hit in the search result. Contains the found document as an instance of class EsDocument. This class resides in assembly Smartsite.EnterpriseSearch.Base.
SnippetBuilder internal class Builds a snippet, preferably using a highlighted fragment, else using a field of the found document. The result snippet is set in in the above SearchResultEntry.
SearchResultAggregationEntry class This is one distinct aggregation value, with a count of the number of occurrences in the search result.
SearchResultAggregation class This is a set of aggregation entries for one field / for one aggregation request. Multiple sets can be present in the search result.
SearchResult class Search result as returned to the search application. It contains a list of search result entries, a list of search result aggregations and more, for example the current search result page.

Xml result classes

Class SearchResult can return xml for the search result. This provides access from for example PHP environments that are remote and/or that cannot access .net assemblies.

Name Type Purpose
SearchResultXmlSettings class Settings for the xml to return, for example whether to include the document associated with each search result hit.

Helper classes

Helper classes

Helper classes are not specifically search classes or result classes. Helper classes are included if used by the search or result classes, or if they could be useful for the search application.

Name Type Purpose
UrlBuilder class Abstract base class for url builder classes.
DefaultUrlBuilder class Url builder that supports to read and modify a name-value collection that corresponds to the query arguments of the url.