Implementing Boolean search with the API

Using requests to the Conversation Web Service, you can specify a Boolean search mode for any search request that performs value or attribute search, or a search request against defined search interfaces. You can also use Boolean search in record and attribute filters. This topic includes examples of these types of requests.

Before using search on any attributes, ensure that attributes are configured for either record search and/or managed attribute value search. For information, see Enabling value search.

Boolean search in value search

In this example, Boolean search mode is used for a value search made with the ValueSearchConfig type:
<ns:ContentElementConfig 
   Id="ValueSearchConfig" 
   xsi:type="ns:ValueSearchConfig" 
   HandlerNamespace="http://www.endeca.com/MDEX/conversation/1/0"
   HandlerFunction="ValueSearchHandler"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   Mode="Boolean">
  <ns:SearchTerm>"Bike Racks" AND "Handlebars"</ns:SearchTerm>
</ns:ContentElementConfig>

Boolean search in record filters

You can use strings that specify Boolean search as input for the RecordFilter operator:
<ns:Operator 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:type="ns:RecordFilterOperator">
   <ns:RecordFilter 
     Name="OmitSystemRecords">AND(NOT(mdex-config_Key),NOT(mdex-property_Key),NOT(mdex-dimension_Key))
   </ns:RecordFilter>
</ns:Operator>

Boolean search in attribute filters

When you set up the attributes for which to search using the SearchFilter operator, you also set a match mode that should be used for search. To use boolean search for the search mode, you set the match mode to Boolean. The following example illustrates the SearchFilter that uses Boolean search:
<ns:SearchFilter Mode="Boolean" Key="Description">Mountain</ns:SearchFilter>

Boolean search in search interfaces

Before you use Boolean search against search interfaces, you need to configure one or more search interfaces that include all of the attributes that you want to search. This is done through the putConfigDocuments operation of the Configuration Web Service, by sending in an XML configuration document RECSEARCH_CONFIG. For information on how to send XML configuration documents to the Oracle Endeca Server, see tdg_configWS_adding_xml_config_doc.html#009665nb04AE35FD9C74A8194B717.

Now you can create a single Boolean search request against the defined search interfaces:
<ns:Operator 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xsi:type="ns:SearchOperator" Within="false">
  <ns:SearchFilter Key="All" Mode="Boolean">English : one AND Spanish : dos</ns:SearchFilter>
</ns:Operator>