This namespace documents the WCF web services that are used to programmatically interact with an Ankiro Suite installation.
Interfaces
Interface | Description | |
---|---|---|
![]() | IDocumentWebService |
The IDocumentWebService is used as the main entrypoint to transmit and update data. Each of the interface methods interacts with a pre-configured data source, as created through the web site or through the management web service. The service contains methods both for handling incremental data source updates, as well as for fully updating data for the data source. Examples using System; using System.Collections.Generic; using System.Linq; using Ankiro.SearchServer.Data; namespace Ankiro.Suite.Client.IndexingSample { public class Program { static void Main(string[] args) { var program = new Program(); program.Run(); } private readonly ManagementService.ManagementWebServiceClient _managementService; private readonly DocumentService.DocumentWebServiceClient _documentService; private readonly DataSourceData _dataSource; private Program() { _dataSource = new DataSourceData { Name = "Sample Datasource" }; var clientFactory = ClientFactory.CreateDefaultClientFactory(new Uri(System.Configuration.ConfigurationManager.AppSettings["AnkiroSuiteLocation"])); _managementService = clientFactory.CreateManagementServiceClient(); _documentService = clientFactory.CreateDocumentServiceClient(); } private void Run() { var dataSource = _managementService.GetDataSourceByName(_dataSource.Name) ?? CreateDataSource(); SetupIndex(dataSource); IndexSampleData(dataSource); DeleteDocument(dataSource, "1"); } private void DeleteDocument(DataSourceData dataSource, string uri) { _documentService.ProcessDocuments(dataSource.Id, new[] { new DocumentData { Uri = uri, Action = DocumentAction.Remove } }); _documentService.Commit(dataSource.Id); } private void IndexSampleData(DataSourceData dataSource) { _documentService.ProcessDocuments(dataSource.Id, CreateSampleDocuments().ToArray()); _documentService.Commit(dataSource.Id); } private void SetupIndex(DataSourceData dataSource) { Console.WriteLine("DataSource id: " + dataSource.Id); var exisingIndex = _managementService.GetIndexByName(dataSource.Name); if (exisingIndex != null) return; var newIndex = _managementService.CreateIndexBasedOnDataSource(dataSource.Id); Console.WriteLine("Index created based on datasource. ServerIndex id: " + newIndex.Id); } private DataSourceData CreateDataSource() { _dataSource.Properties = new List<DataSourcePropertyData> { new DataSourcePropertyData { Name = "Title", Type = IndexPropertyType.ShortText, DefaultValue = "No title", Sortable = true, ItemListProperty = false, }, new DataSourcePropertyData { Name = "Text" , Type = IndexPropertyType.Text , Sortable = false, ItemListProperty = false,}}; return _managementService.CreateDataSource(_dataSource); } private static IEnumerable<DocumentData> CreateSampleDocuments() { var documents = new List<DocumentData> { new DocumentData { Uri = "1", FriendlyUri = String.Format("http://mysite/showDocumentById?id={0}", "1"), Properties = new List<DocumentPropertyData>( new[]{ new DocumentPropertyData{Name = "Title",Value = "Document Title"}, new DocumentPropertyData{Name = "Text",Value = "Document Text"} }), Language = "da", }, new DocumentData { Uri = "2", FriendlyUri = String.Format("http://mysite/showDocumentById?id={0}", "2"), Properties = new List<DocumentPropertyData>( new[]{ new DocumentPropertyData{Name = "Title",Value = "Document Title 2"}, new DocumentPropertyData{Name = "Text",Value = "Document Text 2"} }), Language = "da", } }; return documents; } } } |
![]() | ILanguageAnalyzeWebService |
The language analyse service is used to setup and perform automated language analysis.
|
![]() | ILanguageManagementWebService |
The language management service is used for managing thesauri as well as showing languages.
|
![]() | IManagementWebService |
The management service is used as the main entrypoint to manipulate the primary entities of an Ankiro Suite installation.
Examples using System; using System.Collections.Generic; using System.Linq; using Ankiro.SearchServer.Data; namespace Ankiro.Suite.Client.IndexingSample { public class Program { static void Main(string[] args) { var program = new Program(); program.Run(); } private readonly ManagementService.ManagementWebServiceClient _managementService; private readonly DocumentService.DocumentWebServiceClient _documentService; private readonly DataSourceData _dataSource; private Program() { _dataSource = new DataSourceData { Name = "Sample Datasource" }; var clientFactory = ClientFactory.CreateDefaultClientFactory(new Uri(System.Configuration.ConfigurationManager.AppSettings["AnkiroSuiteLocation"])); _managementService = clientFactory.CreateManagementServiceClient(); _documentService = clientFactory.CreateDocumentServiceClient(); } private void Run() { var dataSource = _managementService.GetDataSourceByName(_dataSource.Name) ?? CreateDataSource(); SetupIndex(dataSource); IndexSampleData(dataSource); DeleteDocument(dataSource, "1"); } private void DeleteDocument(DataSourceData dataSource, string uri) { _documentService.ProcessDocuments(dataSource.Id, new[] { new DocumentData { Uri = uri, Action = DocumentAction.Remove } }); _documentService.Commit(dataSource.Id); } private void IndexSampleData(DataSourceData dataSource) { _documentService.ProcessDocuments(dataSource.Id, CreateSampleDocuments().ToArray()); _documentService.Commit(dataSource.Id); } private void SetupIndex(DataSourceData dataSource) { Console.WriteLine("DataSource id: " + dataSource.Id); var exisingIndex = _managementService.GetIndexByName(dataSource.Name); if (exisingIndex != null) return; var newIndex = _managementService.CreateIndexBasedOnDataSource(dataSource.Id); Console.WriteLine("Index created based on datasource. ServerIndex id: " + newIndex.Id); } private DataSourceData CreateDataSource() { _dataSource.Properties = new List<DataSourcePropertyData> { new DataSourcePropertyData { Name = "Title", Type = IndexPropertyType.ShortText, DefaultValue = "No title", Sortable = true, ItemListProperty = false, }, new DataSourcePropertyData { Name = "Text" , Type = IndexPropertyType.Text , Sortable = false, ItemListProperty = false,}}; return _managementService.CreateDataSource(_dataSource); } private static IEnumerable<DocumentData> CreateSampleDocuments() { var documents = new List<DocumentData> { new DocumentData { Uri = "1", FriendlyUri = String.Format("http://mysite/showDocumentById?id={0}", "1"), Properties = new List<DocumentPropertyData>( new[]{ new DocumentPropertyData{Name = "Title",Value = "Document Title"}, new DocumentPropertyData{Name = "Text",Value = "Document Text"} }), Language = "da", }, new DocumentData { Uri = "2", FriendlyUri = String.Format("http://mysite/showDocumentById?id={0}", "2"), Properties = new List<DocumentPropertyData>( new[]{ new DocumentPropertyData{Name = "Title",Value = "Document Title 2"}, new DocumentPropertyData{Name = "Text",Value = "Document Text 2"} }), Language = "da", } }; return documents; } } } |
![]() | ISearchLoggingWebService |
The search logging service is used primarily to log information about user clicks on search result pages,
which must necessarily be carried out by the web page presenting the search result.
The service also provides a method for manually creating a search log entry, based on a search result and
a set of search parameters.
Examples using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ankiro.SearchServer.Data.Search; using Ankiro.Suite.Client.SearchLoggingService; using Ankiro.Suite.Client.SearchSample.SearchLoggingService; using Ankiro.Suite.Client.SearchSample.SearchService; using Ankiro.Suite.Client.SearchService; namespace Ankiro.Suite.Client.SearchSample { public class LoggingServiceSample { private SearchLoggingWebService loggingService; private SearchWebService searchService; public LoggingServiceSample(SearchWebService searchWebService, SearchLoggingWebService loggingWebService) { loggingService = loggingWebService; searchService = searchWebService; } public int SearchProfileId { get; set; } public void ExecuteSearchAndLogManually(string searchString) { SearchParameters parameters = new SearchParameters() { SearchProfileId = SearchProfileId, SearchString = searchString, Offset = 0, MaxResults = 10, LogSearch = false, LogSearchParameters = false, Parameters = new Dictionary<string, string>(), SessionId = HttpContext.Current.Session.SessionID, RequestedBy = HttpContext.Current.Request.UserHostAddress, }; parameters.Parameters["document-type"] = "article|news item"; SearchResult result = searchService.Search(parameters); // The process of logging search entries are automatically provided by the search service, // when specifying LogSearch=true. This sample is therefore for demonstration purposes mostly. SearchEntry entry = new SearchEntry() { SearchString = parameters.SearchString, Language = parameters.SearchLanguage, NumResults = result.TotalResults, Timestamp = result.Timestamp, SearchTimeMilliseconds = (int) result.SearchTime.TotalMilliseconds, RequestedBy = parameters.RequestedBy, SessionId = parameters.SessionId, Parameters = new List<SearchEntryParameter>(), }; foreach (var param in parameters.Parameters) { foreach (var val in param.Value.Split('|')) { entry.Parameters.Add(new SearchEntryParameter() { Parameter = param.Key, Value = val, }); } } // Important to update the entry with the persisted version in order to obtain the generated database id. entry = loggingService.LogSearch(SearchProfileId, entry); // Emulate that all documents have been clicked foreach (ResultDocument document in result.Documents) { // This could also have been done by adding the clicks to the entry.Clicks collection before invoking the LogSearch method. loggingService.LogClick( entry.Id, DateTime.Now, document.Id, document.LogicalOffset); } } } } |
![]() | ISearchWebService |
ISearchWebService is used as the main entrypoint to search for matching documents in one or more indexes.
Search is primarily carried out through the Search method, which interacts with a preconfigured search profile
in an installation.
Examples using System; using System.Collections.Generic; using System.Linq; using System.Text; using Ankiro.SearchServer.Data.Search; using Ankiro.SearchServer.Data.Search.Xml; using Ankiro.Suite.Client.DocumentService; using Ankiro.Suite.Client.ManagementService; using Ankiro.Suite.Client.SearchService; namespace Ankiro.Suite.Client.SearchSample { class Program { static void Main(string[] args) { ClientFactory clientFactory = ClientFactory.CreateBasicHttpClientFactory(new Uri("http://develop.danbolig.ankiro.dk/")); SearchWebServiceClient searchService = clientFactory.CreateSearchServiceClient(); var parameters = new SearchParameters { SearchProfileId = 23, Offset = 0, MaxResults = 100, SearchString = "*", SpellcheckSearchString = true, LogSearch = false, LogSearchParameters = false, Parameters = new Dictionary<string, string> { { "fields", "AabentHusDato" }, }, ReturnDiagnostics = true, RefreshCache = true, }; parameters.AddParameter("Sort", new Parameter() { Item = new CompoundList() { Compound = new Compound[] { new Compound() { Field = new NamedField[] { new NamedField("sort-by", "AabentHusDato"), new NamedField("sort-by-direction", "ascending") , } } } } }); // SearchProfileId must refer to a search profile created through the web interface or through the management service. var result = searchService.Search(parameters); Console.WriteLine("Number of results: " + result.TotalResults); foreach (var document in result.Documents) { Console.WriteLine(document.Uri + ": " + document.Properties.Single(x => x.Name == "AabentHusDato").Value); } Console.ReadKey(); } } } |
![]() | ISemanticExpandWebService |
The scemantic expand service is used in custom setups where the regular search engine with built-in word expansions cannot be used.
A semantic expansion of a word provides the various forms of the words as defined in the system.
|
![]() | ISpellcheckWebService |
The spellcheck service exposes the spellchecking functionality used by the search engine.
|
![]() | IStatisticsWebService |
The statistics services provides access to updating, clearing and exporting statistics.
|
![]() | ITermListWebService |
The term list services provides management of term lists. Term lists are used for spellchecking in certain scenarios where the thesaurus spellchecking does not apply.
For instance, a search field searching only person names should only spellcheck against the specific list of names and not words in general.
|
![]() | IThesaurusWebService |
The language service provides access to language and thesauri data in an installation, as well as exposing methods for
accessing the built-in spellchecker.
|