In order to run these examples, make sure that the default corpus is populated as described in the Installation guide.
Creating combined {semantic + keyword} queries
The combined {semantic + keyword} query is actually a new enhancement to the existing SemanticQuery. It consists of a semantic part and a keyword part. By binding semantic variables, they are connected to specific document fields, where the search is performed. Therefore, you can now search not only for documents matching specific entities, but also extend this query and find documents in which these entities appear together with other entities or terms.
Example: To find all People whose name starts with "John" and at the same time are included in documents with the word "fraud" in their titles and Organization in their bodies.
The element that joins these two searches is the document binding condition, that the searched locations should be contained in the "body" field of the document.
You can easily have two or more semantic variables bound, so you can search for co-existing entities. However, the current implementation restricts you to have these variables related in the preceding semantic part (i.e. you must ensure that the semantic part is canonical). The code below will give you all pairs of organizations and locations that have the "locatedIn" relation, are in the same documents, and the document set is restricted by some keywords.
Browsing results
When you execute such a complex query, you can request both entities and documents. As you can see in the code below, this cannot be done simultaneously. You can use the different methods of the API:
The Result Flags in the entity and document results indicate if some limits were reached during the execution of the query and if the results were truncated. These limits have default values but you can also change them at runtime. For more details about each of them and how to change their values at the beginning, please see the Configuring the Semantic Repository and Configuring the Document Repository sections.