Excluding results from search based on a boolean


(Mark Evans) #1

Currently my search results return all records within my index.

However i wish to have the option to exclude certain records from the search results based on a boolean value in one of the index record fields.

How would i incorporate this into my existing query?

.Query(a =>
{
return
a.Match(m => m.OnField("_all").Query(strSearchQuery).Operator(Operator.And))
&& a.TermsDescriptor(t => t.OnField(f => f.Type).MinimumShouldMatch("100%").Terms(lstSelectedTypes))
&& a.TermsDescriptor(t => t.OnField(f => f.Section).MinimumShouldMatch("100%").Terms(lstSections))
&& a.Range(t => t.OnField(f => f.CreatedDate).GreaterOrEquals(DateFrom));
}

I want to add some condition that would check if a global boolean flag is set to to true then the records in the index with a certain boolean field set to true will be ignored within the search query...

if the global boolean flag is false we just use the query as is now and allow all index records through...


(system) #2