Assembly: Search


Classes in assembly Smartsite.EnterpriseSearch.Search can be used to implement a search application in a .net environment.

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 (which in turn mimic query components used by Lucene).

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 Type Purpose
BaseQuery class Abstract base class for parts of the search query.
BoolQuery class Boolean compound query. It contains a set of must-queries, a set of should-queries, and a set of must-not-queries.
MultiMatchQuery class Query that uses the search words for a search in multiple fields of a document, for example to search "test word" in fields doc_title and doc_body.
TermsQuery class Query that compares one or more terms to a field of a document, for example compares one or more keywords to field doc_keywords.
BoolQueryOccurrenceType enum Enumeration of the above boolean query occurrence types: Must, Should and MustNot.
BoolQuerySearchClause class Auxiliary class to combine a BoolQueryOccurrenceType with a MultiMatchQuery. Currently unused.
MultiMatchQueryType enum 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.

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 filtering the search result given aggregation values.

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

Name Type Purpose
SearchQueryAggregation class Represents the aggregation request for one document field. Multiple aggregation requests can be added to the search specification. The aggregation request can optionally be populated with values for the aggregation, causing the search result to be reduced to hits having these values.
SearchQueryAggregationType enum Enumeration of aggregation types: Terms, Cardinality or DateRange. Terms is the default and results in a count per value, for each distinct values found in the field. Cardinality is currently unused. DateRange is currently not implemented. Several other aggregation types exists, currently not supported.

Presentation classes

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

Name Type Purpose
SortParameter class Specification of a field for result ordering, and whether this should be ascending or descending.
HighlightRequest class 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. The enumeration expresses 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.