Class QueryService
- Namespace
- Dynamicweb.Indexing.Querying
- Assembly
- Dynamicweb.Core.dll
Service for working with stored queries and their facet groups — loading, saving, moving, copying and deleting them on disk — and for executing a query against its source provider.
public class QueryService : IQueryService
- Inheritance
-
QueryService
- Implements
- Inherited Members
Remarks
Queries are persisted as .query files and facet groups as .facets files. Both can be addressed
either by an absolute file path or by a (repository, item) pair resolved relative to the system repositories root.
Resolve an instance from DI via DependencyResolver.Current.GetRequiredService<IQueryService>() or constructor injection.
Methods
CopyQuery(string, IQuery)
Creates a copy of an existing query at a new location, leaving the original in place and duplicating its configuration.
public ApplicationResponse<IQuery> CopyQuery(string fileName, IQuery query)
Parameters
fileNamestringThe absolute destination path for the new copy, including the file name (e.g.
...\MyQueryCopy.query); the copy's Name is derived from this file name. Must not already exist; the destination folder is created if it is missing.queryIQueryThe source query to copy from. It is not modified.
Returns
- ApplicationResponse<IQuery>
A succeeded response carrying the newly created copy, or a failed response whose message explains why (empty or duplicate destination).
DeleteQuery(IQuery)
Deletes the given query, removing its file (if present) and configuration.
public void DeleteQuery(IQuery query)
Parameters
queryIQueryThe query to delete.
DeleteQuery(string)
Deletes the query with the given id, removing its file and configuration. Does nothing if queryId is not a valid GUID or no matching query exists.
public void DeleteQuery(string queryId)
Parameters
queryIdstringThe query's unique id, as a GUID string.
LoadFacets(string)
Loads the facet group stored at an absolute file path.
public IFacetGroup? LoadFacets(string fileName)
Parameters
fileNamestringAbsolute path to the facets file; the
.facetsextension is applied automatically.
Returns
- IFacetGroup
The loaded facet group, or null if
fileNameis empty or the file does not exist.
LoadFacets(string, string)
Loads the facet group stored at item within repository, resolved relative to the system repositories root.
public IFacetGroup? LoadFacets(string repository, string item)
Parameters
repositorystringThe repository folder name. Paths and names consisting only of dots after trimming whitespace are not accepted.
itemstringThe facet group file name within
repository. The.facetsextension is applied automatically. Paths and names consisting only of dots after trimming whitespace are not accepted.
Returns
- IFacetGroup
The loaded facet group, or null if either argument is not a valid name or no matching facets file exists.
LoadQuery(string)
Loads the query stored at an absolute file path.
public IQuery? LoadQuery(string fileName)
Parameters
fileNamestringAbsolute path to the query file; the
.queryextension is applied automatically.
Returns
LoadQuery(string, string)
Loads the query stored at item within repository, resolved relative to the system repositories root.
public IQuery? LoadQuery(string repository, string item)
Parameters
repositorystringThe repository folder name. Paths and names consisting only of dots after trimming whitespace are not accepted.
itemstringThe query file name within
repository. The.queryextension is applied automatically. Paths and names consisting only of dots after trimming whitespace are not accepted.
Returns
- IQuery
The loaded query, or null if either argument is not a valid name or no matching query file exists.
MoveQuery(string, IQuery)
Moves an existing query file to a new location, taking its saved configuration with it.
The query is read from its current path (query's FileName) and relocated to fileName.
public ApplicationResponse<IQuery> MoveQuery(string fileName, IQuery query)
Parameters
fileNamestringThe absolute destination path the query file is moved to, including the file name (e.g.
...\MyQuery.query). Must differ from the query's current path and must not already exist; the destination folder is created if it is missing.queryIQueryThe existing query to move. Its FileName must point to the current file and is updated to
fileNameon success.
Returns
- ApplicationResponse<IQuery>
A succeeded response carrying the moved query, or a failed response whose message explains why (empty or duplicate destination, missing source file, or a move to the same location).
Query(IQuery, QuerySettings)
Executes query against its source provider and returns the result.
public IQueryResult? Query(IQuery query, QuerySettings settings)
Parameters
queryIQueryThe query to execute.
settingsQuerySettingsSettings controlling execution, such as paging.
Returns
- IQueryResult
The query result, or null if the query's source has no provider.
SaveFacets(string, IFacetGroup)
Saves facets to an absolute file path, creating the file or updating it in place. The .facets extension is applied automatically.
public void SaveFacets(string fileName, IFacetGroup facets)
Parameters
fileNamestringAbsolute path to the facets file.
facetsIFacetGroupThe facet group to save.
SaveFacets(string, string, IFacetGroup)
Saves facets to item within repository, resolved relative to the system repositories root.
public void SaveFacets(string repository, string item, IFacetGroup facets)
Parameters
repositorystringRepository (folder) name under the repositories root.
itemstringItem (file) name within the repository.
facetsIFacetGroupThe facet group to save.
SaveQuery(string, IQuery)
Saves query to an absolute file path, creating the file or updating it in place.
The .query extension is applied automatically, and if the file's name differs from query's Name the file is renamed to match.
public void SaveQuery(string fileName, IQuery query)
Parameters
SaveQuery(string, string, IQuery)
Saves query to item within repository, resolved relative to the system repositories root.
public void SaveQuery(string repository, string item, IQuery query)