Shingle Rewriter

The Shingle Rewriter combines adjacent query tokens into a new token and adds this token to the query as a synonym. For example, if the user searches for ‘wall mount tv’, it would create the tokens ‘wallmount’ and ‘mounttv’ and add them as synonyms, improving the recall of documents containing the compound form ‘wallmount’.

This rewriter is only available for Solr. You might want to consider using the more powerful Word Break Rewriter for both, Solr and Elasticsearch. Amongst other features, the Word Break Rewriter also allows to add shingles to the query. It adds the option to validate the newly created token against tokens in a ‘dictionary field’.

Due to its simplicity, the source code of the Shingle Rewriter is also a good starting point for writing your own rewriter.

Reference

Configuration

Querqy 5

POST /solr/mycollection/querqy/rewriter/shingle?action=save
Content-Type: application/json
1{
2    "class": "querqy.solr.rewriter.ShingleRewriterFactory",
3    "config": {
4        "acceptGeneratedTerms": false
5    }
6}

Querqy 4

<lst name="rewriter">
  <str name="class">querqy.solr.contrib.ShingleRewriterFactory</str>
  <bool name="acceptGeneratedTerms">false</bool>
</lst>
acceptGeneratedTerms

If true, also create shingle tokens from terms that were created by other rewriters earlier in the rewrite chain. Otherwise, only create shingles for tokens found in the original user query.

Default: false