Implements necessary functions to use Elasticsearch as a search engine.
More...
|
| ElasticsearchSearchClient (string server="localhost", string port="9200") |
|
void | ChangeIndex (string index) |
| Updates the current index. More...
|
|
async Task< IDictionary< string, string > > | GetMappingAsync () |
| Queries the mappings of the current index. More...
|
|
async Task | CreateIndexAsync (JObject content, string index) |
| Creates an index with the given settings and mappings. More...
|
|
async Task | AddDocumentsAsync (IEnumerable< JObject > documents) |
| Adds the given documents as a bulk upload. More...
|
|
async Task | SwitchAliasAsync (string from, string to) |
| Changes the alias from the old to the new index. More...
|
|
async Task | DeleteIndexAsync (string index) |
| Deletes the given index. More...
|
|
async Task | AddDocumentAsync (string graphName, IDictionary< string, JObject > documents) |
| Adds/updates a new document and possibly changes existing documents. More...
|
|
async Task | DeleteDocumentAsync (string graphName, IDictionary< string, JObject > documents) |
| Deletes a document and possibly changes other existing documents. More...
|
|
async Task< IDictionary< string, double > > | SearchAsync (string query, IEnumerable< string > projects, bool advanced, int size, int from, string sorting) |
| Searches the index using the alias. More...
|
|
|
async Task< string > | GetIdFromGraphNameAsync (string graphName) |
| Queries the document ID for a metadata graph. More...
|
|
void | HandleResponse (HttpResponseMessage response) |
| Handles response of a HTTP request. More...
|
|
HttpContent | CreateJsonContent (JObject content) |
|
HttpContent | CreateJsonContent (string content) |
|
async Task< List< string > > | AddOtherDocuments (List< string > contentList, KeyValuePair< string, JObject > document) |
| Creates the content list for a bulk request with the given documents. More...
|
|
async Task | BulkRequestAsync (IEnumerable< string > contentList) |
| Executes a bulk request with the given list of content. More...
|
|
JProperty | CreateVisibilityFilter (IEnumerable< string > projects) |
| Creates the visibility filter for search to allow a user only to see public metadata or metadata of own projects. More...
|
|
async Task< IDictionary< string, double > > | Search (JObject content) |
| Runs the search and handles the response. More...
|
|
IDictionary< string, double > | GetSearchResults (JObject results) |
| Filters the plain search results of a search request. More...
|
|
|
const string | ALIASES = "_aliases" |
|
const string | SEARCH = "_search" |
|
const string | MAPPING = "_mapping" |
|
const string | BULK = "_bulk" |
|
static readonly HttpClient | client = new HttpClient() |
|
Implements necessary functions to use Elasticsearch as a search engine.
◆ ElasticsearchSearchClient()
SemanticSearchImplementation.ElasticsearchSearchClient.ElasticsearchSearchClient |
( |
string |
server = "localhost" , |
|
|
string |
port = "9200" |
|
) |
| |
|
inline |
◆ AddDocumentAsync()
async Task SemanticSearchImplementation.ElasticsearchSearchClient.AddDocumentAsync |
( |
string |
graphName, |
|
|
IDictionary< string, JObject > |
documents |
|
) |
| |
|
inline |
Adds/updates a new document and possibly changes existing documents.
Additional rules can influence the mapping of existing metadata graphs.
- Parameters
-
graphName | ID of the metadata graph to be added/updated. |
documents | A dictionary containing the ID of metadata graphs (key) and corresponding JSON objects (value). |
- Returns
- A task that represents the asynchronous save operation.
Implements SemanticSearchImplementation.ISearchClient.
◆ AddDocumentsAsync()
async Task SemanticSearchImplementation.ElasticsearchSearchClient.AddDocumentsAsync |
( |
IEnumerable< JObject > |
documents | ) |
|
|
inline |
Adds the given documents as a bulk upload.
- Parameters
-
documents | An enumerator of all documents as JSON object. |
- Returns
- A task that represents the asynchronous save operation.
Implements SemanticSearchImplementation.ISearchClient.
◆ AddOtherDocuments()
async Task<List<string> > SemanticSearchImplementation.ElasticsearchSearchClient.AddOtherDocuments |
( |
List< string > |
contentList, |
|
|
KeyValuePair< string, JObject > |
document |
|
) |
| |
|
inlineprivate |
Creates the content list for a bulk request with the given documents.
- Parameters
-
contentList | A list containing the content for the bulk request. |
document | IDs of metadata graphs (key) and their correcsponding content as JSON object (value). |
- Returns
- The task result contains the created content list for the bulk request.
◆ BulkRequestAsync()
async Task SemanticSearchImplementation.ElasticsearchSearchClient.BulkRequestAsync |
( |
IEnumerable< string > |
contentList | ) |
|
|
inlineprivate |
Executes a bulk request with the given list of content.
- Parameters
-
contentList | An enumerator of content rows for the bulk request. |
- Returns
- A task that represents the asynchronous save operation.
◆ ChangeIndex()
void SemanticSearchImplementation.ElasticsearchSearchClient.ChangeIndex |
( |
string |
index | ) |
|
|
inline |
◆ CreateIndexAsync()
async Task SemanticSearchImplementation.ElasticsearchSearchClient.CreateIndexAsync |
( |
JObject |
content, |
|
|
string |
index |
|
) |
| |
|
inline |
Creates an index with the given settings and mappings.
- Parameters
-
content | JSON object containing the settings and mappings. |
index | The index name. |
- Returns
- A task that represents the asynchronous save operation.
Implements SemanticSearchImplementation.ISearchClient.
◆ CreateJsonContent() [1/2]
HttpContent SemanticSearchImplementation.ElasticsearchSearchClient.CreateJsonContent |
( |
JObject |
content | ) |
|
|
inlineprivate |
◆ CreateJsonContent() [2/2]
HttpContent SemanticSearchImplementation.ElasticsearchSearchClient.CreateJsonContent |
( |
string |
content | ) |
|
|
inlineprivate |
◆ CreateVisibilityFilter()
JProperty SemanticSearchImplementation.ElasticsearchSearchClient.CreateVisibilityFilter |
( |
IEnumerable< string > |
projects | ) |
|
|
inlineprivate |
Creates the visibility filter for search to allow a user only to see public metadata or metadata of own projects.
- Parameters
-
projects | An enumerator containing the projects which are allowed. |
- Returns
- A JProperty containing the specified visibility filter.
◆ DeleteDocumentAsync()
async Task SemanticSearchImplementation.ElasticsearchSearchClient.DeleteDocumentAsync |
( |
string |
graphName, |
|
|
IDictionary< string, JObject > |
documents |
|
) |
| |
|
inline |
Deletes a document and possibly changes other existing documents.
Additional rules can influence the mapping of existing metadata graphs.
- Parameters
-
graphName | ID of the metadata graph to be deleted. |
documents | A dictionary containing the ID of metadata graphs (key) and corresponding JSON objects (value). |
- Returns
- A task that represents the asynchronous delete operation.
Implements SemanticSearchImplementation.ISearchClient.
◆ DeleteIndexAsync()
async Task SemanticSearchImplementation.ElasticsearchSearchClient.DeleteIndexAsync |
( |
string |
index | ) |
|
|
inline |
◆ GetIdFromGraphNameAsync()
async Task<string> SemanticSearchImplementation.ElasticsearchSearchClient.GetIdFromGraphNameAsync |
( |
string |
graphName | ) |
|
|
inlineprivate |
Queries the document ID for a metadata graph.
- Parameters
-
graphName | ID of the metadata graph. |
- Returns
- ID of the Elasticsearch document.
◆ GetMappingAsync()
async Task<IDictionary<string, string> > SemanticSearchImplementation.ElasticsearchSearchClient.GetMappingAsync |
( |
| ) |
|
|
inline |
◆ GetSearchResults()
IDictionary<string, double> SemanticSearchImplementation.ElasticsearchSearchClient.GetSearchResults |
( |
JObject |
results | ) |
|
|
inlineprivate |
Filters the plain search results of a search request.
- Parameters
-
results | Plain JSON result of a search request. |
- Returns
- A dictionary containing the ID of the metadata graphs (key) and the corresponding rankings (value),
◆ HandleResponse()
void SemanticSearchImplementation.ElasticsearchSearchClient.HandleResponse |
( |
HttpResponseMessage |
response | ) |
|
|
inlineprivate |
Handles response of a HTTP request.
- Parameters
-
response | The response of a HTTP request. |
◆ Search()
async Task<IDictionary<string, double> > SemanticSearchImplementation.ElasticsearchSearchClient.Search |
( |
JObject |
content | ) |
|
|
inlineprivate |
Runs the search and handles the response.
- Parameters
-
content | A JSON object containing the body of the search request. |
- Returns
- The task result contains a dictionary containing the IDs of the found metadata graphs (key) and the corresponding ranking (value).
◆ SearchAsync()
async Task<IDictionary<string, double> > SemanticSearchImplementation.ElasticsearchSearchClient.SearchAsync |
( |
string |
query, |
|
|
IEnumerable< string > |
projects, |
|
|
bool |
advanced, |
|
|
int |
size, |
|
|
int |
from, |
|
|
string |
sorting |
|
) |
| |
|
inline |
Searches the index using the alias.
- Parameters
-
- Returns
- The task result contains a dictionary containing the IDs of the found metadata graphs (key) and the corresponding ranking (value).
Implements SemanticSearchImplementation.ISearchClient.
◆ SwitchAliasAsync()
async Task SemanticSearchImplementation.ElasticsearchSearchClient.SwitchAliasAsync |
( |
string |
from, |
|
|
string |
to |
|
) |
| |
|
inline |
◆ _index
string SemanticSearchImplementation.ElasticsearchSearchClient._index |
|
private |
◆ ALIASES
const string SemanticSearchImplementation.ElasticsearchSearchClient.ALIASES = "_aliases" |
|
staticprivate |
◆ baseUrl
readonly string SemanticSearchImplementation.ElasticsearchSearchClient.baseUrl |
|
private |
◆ BULK
const string SemanticSearchImplementation.ElasticsearchSearchClient.BULK = "_bulk" |
|
staticprivate |
◆ client
readonly HttpClient SemanticSearchImplementation.ElasticsearchSearchClient.client = new HttpClient() |
|
staticprivate |
◆ MAPPING
const string SemanticSearchImplementation.ElasticsearchSearchClient.MAPPING = "_mapping" |
|
staticprivate |
◆ SEARCH
const string SemanticSearchImplementation.ElasticsearchSearchClient.SEARCH = "_search" |
|
staticprivate |
The documentation for this class was generated from the following file: