Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<IncludeAssets>all</IncludeAssets>
</PackageReference>

<PackageReference Include="Documaster.WebApi.Client.Noark5" Version="0.10.0">
<PackageReference Include="Documaster.WebApi.Client.Noark5" Version="0.12.1">
<IncludeAssets>all</IncludeAssets>
</PackageReference>
<PackageReference Include="Documaster.WebApi.Client.IDP" Version="1.0.0">
Expand Down
88 changes: 87 additions & 1 deletion NoarkWsClientSample/NoarkWsClientSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void Main(string[] args)
MeetingAndBoardHandlingDataSample();
BusinessSpecificMetadataSample();
CodeListsSample();
FullTextSearchSample();
}

private static Options ParserCommandLineArguments(string[] args)
Expand Down Expand Up @@ -81,7 +82,7 @@ private static void InitIdpClient(Options options)

private static void InitClient(Options options)
{
client = new NoarkClient(options.ServerAddress, options.CertificatePath, options.CertificatePass, true);
client = new NoarkClient(options.ServerAddress, true, options.CertificatePath, options.CertificatePass);
}

private static void InitClientWithoutClientCertificate(Options options)
Expand Down Expand Up @@ -731,6 +732,91 @@ private static void CodeListsSample()
Console.WriteLine($"Deleted code value");
Console.WriteLine();
}

private static void FullTextSearchSample()
{
//NB: The search below, if executed right after the creation of an Arkivdel, won't return
//the Arkivdel in the search results. The time needed to update the search index depends on
//the specific installation. The RMS update interval defaults to 30 seconds.

Console.WriteLine($"Full-text search example");

//Create a new Arkiv with an Arkivskaper
//Create a new Arkivdel in the Arkiv
var newArkivskaper = new Arkivskaper("B7-23-W5", "John Smith");
var newArkiv = new Arkiv("test");
var newArkivdel = new Arkivdel("2007/8");

var transactionResponse = client.Transaction()
.Save(newArkiv)
.Save(newArkivskaper)
.Save(newArkivdel)
.Link(newArkiv.LinkArkivskaper(newArkivskaper))
.Link(newArkivdel.LinkArkiv(newArkiv))
.Commit();

//The time needed to update the search index depends on the specific installation. The RMS update interval defaults
//to 30 seconds.

//Search for 'test' in multiple object types
Search search = client.Search(Doctype.Tekst, "test");
search.Limit = 10;
SearchResponse response = search.Execute();
foreach (SearchResult result in response.Results)
{
Console.WriteLine($"Search result:");
Console.WriteLine($" Ids:");
foreach (string idField in result.Ids.Keys)
{
Console.WriteLine($" {idField}: {String.Join(",", result.Ids[idField])}");
}
Console.WriteLine($" Highlights:");
foreach (string matchingField in result.Highlights.Keys)
{
Console.WriteLine($" {matchingField}: {String.Join(",", result.Highlights[matchingField])}");
}
Console.WriteLine(Environment.NewLine);
}

Console.WriteLine(Environment.NewLine);

foreach (Facet facet in response.Facets)
{
Console.WriteLine($"Facet:");
Console.WriteLine($"Field: {facet.Field}");
Console.WriteLine($"Values: {String.Join(", ", facet.Values)}");
Console.WriteLine(Environment.NewLine);
}

//Search for 'test' in Akrivdel
search = client.Search(Doctype.Arkivdel, "test");
response = search.Execute();
foreach (SearchResult result in response.Results)
{
Console.WriteLine($"Search result:");
Console.WriteLine($" Ids:");
foreach (string idField in result.Ids.Keys)
{
Console.WriteLine($" {idField}: {String.Join(",", result.Ids[idField])}");
}
Console.WriteLine($" Highlights:");
foreach (string matchingField in result.Highlights.Keys)
{
Console.WriteLine($" {matchingField}: {String.Join(",", result.Highlights[matchingField])}");
}
Console.WriteLine(Environment.NewLine);
}

Console.WriteLine(Environment.NewLine);

foreach (Facet facet in response.Facets)
{
Console.WriteLine($"Facet:");
Console.WriteLine($"Field: {facet.Field}");
Console.WriteLine($"Values: {String.Join(", ", facet.Values)}");
Console.WriteLine(Environment.NewLine);
}
}
}

class Options
Expand Down