Ejemplo n.º 1
0
 /// <summary>
 /// Outputs nicely formatted results of a query.
 /// </summary>
 /// <param name="index">The index which was used for the query. Used to obtain documents for displaying them.</param>
 /// <param name="query">String that describes the query</param>
 /// <param name="resultPostingsList">The posting list that was returned from the query.</param>
 static void PrintQueryResult(IIndex index, string query, List <int> resultPostingsList, bool showDocumentText = false)
 {
     Console.WriteLine($"Query '{query}' returned {resultPostingsList.Count} results: {string.Join(", ", resultPostingsList)} ");
     if (showDocumentText)
     {
         foreach (int documentId in resultPostingsList)
         {
             var document = index.Document(documentId);
             Console.WriteLine($"---------------------- Document {documentId} ----------------------");
             Console.WriteLine($"{document.Title}");
             Console.WriteLine($"----------------------------------------------------------");
             Console.WriteLine(document.Text);
             Console.WriteLine($"------------------ End of Document {documentId} -------------------");
             Console.WriteLine();
         }
     }
 }