public HashMap<String, Object> rewrite(Query query,
                                           String dictKey) throws RuntimeException {

        Boolean rewritten = false;

        // Pass the original dict key to the next rewriter
        HashMap<String, Object> result = new HashMap<>();
        result.put(RewriterConstants.REWRITTEN, rewritten);
        result.put(RewriterConstants.DICT_KEY, dictKey);

        RewriterUtils.log(logger, query,
                         "In NameRewriter, query used for dict retrieval=[" + dictKey + "]");

        // Retrieve rewrite from FSA dict using normalized query
        String rewrites = super.getRewriteFromFSA(query, NAME_ENTITY_EXPAND_DICT, dictKey);
        RewriterUtils.log(logger, query, "Retrieved rewrites: " + rewrites);

        // No rewrites
        if(rewrites==null) {
            RewriterUtils.log(logger, query, "No rewrite is retrieved");
            return result;
        }

        // Retrieve max number of rewrites allowed
        int maxNumRewrites = 0;
        String maxNumRewritesStr = getQPConfig(query, RewriterConstants.MAX_REWRITES);
        if(maxNumRewritesStr!=null) {
            maxNumRewrites = Integer.parseInt(maxNumRewritesStr);
            RewriterUtils.log(logger, query,
                              "Limiting max number of rewrites to: " + maxNumRewrites);
        } else {
            RewriterUtils.log(logger, query, "No limit on number of rewrites");
        }

        // Retrieve flags for enabling the features
        String originalAsUnit = getQPConfig(query, RewriterConstants.ORIGINAL_AS_UNIT);
        String originalAsUnitEquiv = getQPConfig(query, RewriterConstants.ORIGINAL_AS_UNIT_EQUIV);
        String rewritesAsUnitEquiv = getQPConfig(query, RewriterConstants.REWRITES_AS_UNIT_EQUIV);
        String rewritesAsEquiv = getQPConfig(query, RewriterConstants.REWRITES_AS_EQUIV);

        // Add proximity boosting to original query and keeping
        // the original query if it's enabled
        if(originalAsUnitEquiv!=null && originalAsUnitEquiv.equalsIgnoreCase("true")) {
            RewriterUtils.log(logger, query, "OriginalAsUnitEquiv is enabled");
            query = RewriterFeatures.addUnitToOriginalQuery(query, dictKey, true);
            RewriterUtils.log(logger, query,
                              "Query after OriginalAsUnitEquiv: " + query.toDetailString());
            rewritten = true;

        // Add proximity boosting to original query
        // if it's enabled
        } else if(originalAsUnit!=null && originalAsUnit.equalsIgnoreCase("true")) {
            RewriterUtils.log(logger, query, "OriginalAsUnit is enabled");
            query = RewriterFeatures.addUnitToOriginalQuery(query, dictKey, false);
            RewriterUtils.log(logger, query,
                              "Query after OriginalAsUnit: " + query.toDetailString());
            rewritten = true;
        }

        // Add rewrites as unit equiv if it's enabled
        if(rewritesAsUnitEquiv!=null && rewritesAsUnitEquiv.equalsIgnoreCase("true")) {
            RewriterUtils.log(logger, query, "RewritesAsUnitEquiv is enabled");
            //query = RewriterFeatures.addRewritesAsEquiv(query, dictKey, rewrites, true, maxNumRewrites);
            query = RewriterFeatures.addRewritesAsEquiv(query, dictKey, rewrites, true, maxNumRewrites);
            RewriterUtils.log(logger, query,
                              "Query after RewritesAsUnitEquiv: " + query.toDetailString());
            rewritten = true;

        // Add rewrites as equiv if it's enabled
        } else if(rewritesAsEquiv!=null && rewritesAsEquiv.equalsIgnoreCase("true")) {
            RewriterUtils.log(logger, query, "RewritesAsEquiv is enabled");
            //query = RewriterFeatures.addRewritesAsEquiv(query, dictKey, rewrites, false, maxNumRewrites);
            query = RewriterFeatures.addRewritesAsEquiv(query, dictKey, rewrites, false, maxNumRewrites);
            RewriterUtils.log(logger, query,
                              "Query after RewritesAsEquiv: " + query.toDetailString());
            rewritten = true;
        }

        RewriterUtils.log(logger, query, "NameRewriter final query: " + query.toDetailString());

        result.put(RewriterConstants.REWRITTEN, rewritten);

        return result;
    }
Main logic of rewriter<br>
- Retrieve rewrites from FSA dict<br>
- rewrite query using features that are enabled by user
container-search/src/main/java/com/yahoo/search/query/rewrite/rewriters/NameRewriter.java