private static void RunQueries(ISearchIndexClient indexClient)
{
SearchParameters parameters;
DocumentSearchResult<Hotel> results;
Console.WriteLine("Search the entire index for the term 'budget' and return only the hotelName field:\n");
parameters =
new SearchParameters()
{
Select = new[] { "hotelName" }
};
results = indexClient.Documents.Search<Hotel>("budget", parameters);
WriteDocuments(results);
Console.Write("Apply a filter to the index to find hotels cheaper than $150 per night, ");
Console.WriteLine("and return the hotelId and description:\n");
parameters =
new SearchParameters()
{
Filter = "baseRate lt 150",
Select = new[] { "hotelId", "description" }
};
results = indexClient.Documents.Search<Hotel>("*", parameters);
WriteDocuments(results);
Console.Write("Search the entire index, order by a specific field (lastRenovationDate) ");
Console.Write("in descending order, take the top two results, and show only hotelName and ");
Console.WriteLine("lastRenovationDate:\n");
parameters =
new SearchParameters()
{
OrderBy = new[] { "lastRenovationDate desc" },
Select = new[] { "hotelName", "lastRenovationDate" },
Top = 2
};
results = indexClient.Documents.Search<Hotel>("*", parameters);
WriteDocuments(results);
Console.WriteLine("Search the entire index for the term 'motel':\n");
parameters = new SearchParameters();
results = indexClient.Documents.Search<Hotel>("motel", parameters);
WriteDocuments(results);
}