Take the community feedback survey now.
AI OnAI Off
Take the community feedback survey now.
You should be able to use Filters right?
var searchHits = client.Search<RemoteHostedContentItem>().Filter(x =>x.Field1.Match(value1) & x.Field2.Match(value2));
Hi. I would use _client.BuildFilter<RemoteHostedContentItem> to build out the filter based on the values that you know. An example of useage would be:
var query = _client.Search<RemoteHostedContentItem>().ExcludeDeleted().CurrentlyPublished();
// Check for values you know
// By wrapping in if statement
// filename is just an example add your fields here
if (!string.IsNullOrEmpty(filename))
{
var NameFilter = _client.BuildFilter<RemoteHostedContentItem>().And(x => x.FileName.Match("filename"));
query = query.Filter(NameFilter);
}
// Example to show adding another Filter to query
// Let's say your type implements this interface which allows you
// To hide a file from search
var SearchableFilter = _client.BuildFilter<IShouldSearch>().And(x => x.IsHiddenFromSearch.Match(false));
// Calling query.Filter multiple times on query adds the querys together, it does not replace the last one
query = query.Filter(SearchableFilter);
var results = query.Skip((page - 1) * pageSize).Take(pageSize).GetContentResult();
Hope this helps!
-John
If I have the code below, but I want to search more than one field for given values that I KNOW, how do I do that?