!--a11y-->
Extending the Search Query 
You can link the user’s search query with another search query that you have defined in a Java class. The user's search query and the search query in the class are linked using AND.

For example, you can define a search for a specific property value in the class (such as property targetgroup = “public”). The index returns only documents for which this value is set.
Your Java class must be derived from the following class:
com.sapportals.wcm.service.indexmanagement.retrieval.search.DefaultQueryExtender
To connect your Java class to an index, create the queryExtender customer property in index administration. You enter the complete name of the Java class as the value (see Creating an Index).
The example below shows a Java class that you can use to extend the search queries for an index:
public class TestQueryExtender extends DefaultQueryExtender{
private AbstractIndex index = null;
public TestQueryExtender(){
}
/**
* has to be implemented the following way
*
* public TestQueryExtender(AbstractIndex index){
* super(index);
* }
*
* @param index
*/
* public TestQueryExtender(AbstractIndex index){
this.index = index;
}
/**
* Return the query which is added to the search for the index
*
* @param qList the standard query list, which will be extended.
* @param context
* @return
* @throws ResourceException
*/
public IQueryEntryList buildAdditionalQuery(IQueryEntryList qList, IResourceContext context)
throws WcmException
{
IQueryEntryList returnList = qList.createEmptyQueryEntryList();
returnList.addContentQuery("test");
returnList.addOrOperator();
returnList.addContentQuery("sap");
return returnList;
}
/**
* @return
*/
public AbstractIndex getIndex() {
return index;
}
}