i am using a azure search, and i have a console app with the code as below, which is working fine.
DocumentSearchResult<Hotel> results;
Console.WriteLine("Search started\n");
results = indexClient.Documents.Search<Hotel>("smart", new SearchParameters { Top=5 });
WriteDocuments(results);
currently its searching a text with word "smart". this is straight forword, what i need is i have several fields in the table, i want to search based on the feild .
for example let i have two fields 1)Title 2)SoldDate
I have to write code for finding items which has title 'john' and which has a sold date < current date.
what should i do to achieve this?
You can achieve what you want with search and a filter:
This will filter the documents to only those with a
soldDate
beforecurrentDate
, and then searches the filtered documents such that documents match if any of the searchable fields contain "john". You can narrow this down to just thetitle
field like this:Or like this:
Which way you use depends on whether you want all search terms to be limited to a specific set of fields (Approach #2), or if you want specific terms to match specific fields (Approach #3).
The reference for
SearchParameters
is on docs.microsoft.com.